Solved

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

Posted on 2015-01-23
4
89 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 33

Expert Comment

by:paulmacd
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

706 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

19 Experts available now in Live!

Get 1:1 Help Now