Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2015-01-23
4
Medium Priority
?
102 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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. …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

604 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