Main Difference Between Class And Object In C++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Main Difference Between Class And Object In C++

Inspite of reading so many time about classes n objects I'm still unable to understand the main difference or you can say their defination. can someone elaborate it please ? Thanks in advance 😊

6th Jun 2017, 12:38 PM
m8riix
m8riix - avatar
6 Answers
+ 5
@Faizal Reza Class is not a subset. It is the set builder form of the object sets that helps define every object... The main difference here is that this set builder form can be used to create more than one set at a time, each being the same or different. So, assume a class as the blueprint of a thing , and the object as a particular model of the thing created using the blueprint... Eg- Suppose you see a basic blueprint of a car, which explains that the car contains wheels, an engine of set horsepower, body of some shape, some mx speed limit, etc, etc... This blueprint can be thought of as a class. Now you use this blueprint to create Bugatti Veryon, as it is a car and will also have all the items listed in the blueprint, just that now, everything will have a fixed value : Eg- 4 wheels, 1248bhp engine, 350miles/h max speed, etc, etc... Thus Bugatti veryon is an object created using the basic blueprint of a standard car...
6th Jun 2017, 1:19 PM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 4
thnx @kinshuk Vasisht
6th Jun 2017, 1:23 PM
m8riix
m8riix - avatar
+ 4
@Faizal Reza Welcome. Happy to help... 😊
6th Jun 2017, 1:24 PM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 2
All Humans (class) talk, walk, and do something, but every person (object) has different names, works, etc.
6th Jun 2017, 12:48 PM
Andrés04_ve
Andrés04_ve - avatar
+ 2
can I say class is subset of object ?
6th Jun 2017, 12:59 PM
m8riix
m8riix - avatar
0
Class is the object type: Human.Object is an element of the class: John.
6th Jun 2017, 12:46 PM
Andrés04_ve
Andrés04_ve - avatar