Solved

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

Posted on 2015-01-23
4
90 Views
Last Modified: 2015-01-23
1. What defines class? What is the difference between class and object?
0
Comment
Question by:Nusrat Nuriyev
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:
Iammontoya 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

929 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now