Solved

1. What defines class? What is the difference between class and object?

Posted on 2015-01-23
4
94 Views
Last Modified: 2015-01-23
1. What defines class? What is the difference between class and object?
0
Comment
Question by:Nusrat Nuriyev
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 40566929
A class is piece of code with properties, events, and methods.

An object is an instance of a class.
0
 
LVL 86

Expert Comment

by:jkr
ID: 40566930
You'll find a comprehensive explanation about C++ classes at http://en.wikipedia.org/wiki/C++_classes

The difference between a class and an object basically is that an object is an instance of a class.
0
 
LVL 19

Accepted Solution

by:
Montoya earned 500 total points
ID: 40566939
here's my child like explanation. Hope it helps.

Let's look at a bike.

as a single object, you can give it properties. Color, Height, Brand, etc...  but what if you need to create 100 bikes, and not all of them will be identical.

That's when you can view classes. If I have a bike class, I can define:

numOfTires:
color:
manufacturer:
height:
frame:

If I was doing an object, I'd have to create properties for each individual bike. With class, I create an object of that class, and it already has those properties attached. I just change the value.

I hope that helps.
0
 
LVL 10

Expert Comment

by:10023
ID: 40567187
You write a file called

Class Something
{
something1 = red;
something2 = blue;
something3 = gray;
}
In another calling file you create an instance of this class by
color.Something    //this is an object

Now as a programmer you can call class in the head of this file and have the c++ privilege of assigning what ever color you allow Class to give it
*******
You can change this on the fly which give you a lot of flexibility
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to convert c++ code to Android App 3 132
Compile GLUT with Visual Studio 2015 1 207
c++ getting the first 10 characters of a char* string 11 105
Precision Problem in C++ 7 52
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question