Solved

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

Posted on 2015-01-23
4
92 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:
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

776 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