what is the different b/w clases and objects? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 9

what is the different b/w clases and objects?

i had tried to understand both of them please tel me some answer

7th Aug 2019, 4:11 AM
Abdullah Hassan Kerkey
Abdullah Hassan Kerkey - avatar
18 Respuestas
+ 18
Think like this. Class is data type (user defined) Object is variable of type 'class' As you must have seen in cpp course class is templates, blueprint for object. Take an example: You make a class of 'fruit'. class fruit{ private: string name; string taste; bool has_seeds; float market_price; }; Once you define a class you can declare objects of that type (class) Like.... fruit mango; //mango is fruit now Now mango is an object of type (class) fruit.. Similar to.. int number; //here we used to declare number as interger. classes allowed programmers to create their own datatypes and organize data in much efficient way by introducing several oop concepts . BTW, how did you complete your course without knowing this 🤔
7th Aug 2019, 4:25 AM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 11
An object is an instance of a class.
7th Aug 2019, 4:15 AM
Sonic
Sonic - avatar
+ 8
Class is the idea (an imagination) of something, it is imaginary, you can't use a class directly because it is unreal. We need to create something real to work with, based on that idea. This real thing we call object - an instance of a class (a real thing created based on the imagination/idea of it). An object is something we can work with, because it is real. The process of creating a real thing (object) from the imagination (class) is called instantiation. We can create (instantiate) multiple instances from a class, just like we can bake many cakes, while all the cakes are baked on the same cake pan and ingredients, that would mean all the cakes will have similar form and flavour (an oversimplified example). Hth, cmiiw
7th Aug 2019, 5:06 AM
Ipang
+ 7
Class is like a blue print. This blue print contains tools (methods, variables, codes etc) to create and manipulate an object. So a class can also be called a container. An object is a real thing created. So its an instance of a class. an object can be created from a class. you can create multiple objects from a single class. P.S: guess we all saying same thing here lol. 🙃🙃
7th Aug 2019, 7:05 AM
BlackRose Mike
BlackRose Mike - avatar
+ 6
A class is like a group, and objects are like the members of the group
7th Aug 2019, 4:28 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 6
Class is a collection of similar objects . Class is just a data type (user defined) and an object is a variable of that data type. Class is just a blueprint for creating objects.
7th Aug 2019, 9:41 AM
Khushi Puri
Khushi Puri - avatar
+ 6
class is a blueprint and object is the product
7th Aug 2019, 3:03 PM
Mouadh Ben Abdallah
Mouadh Ben Abdallah - avatar
7th Aug 2019, 9:47 AM
AU Hameed
AU Hameed - avatar
+ 5
Object is a instance of a class. Which is more likely a copy of the data structure of the class.
8th Aug 2019, 3:11 AM
Manoj
Manoj - avatar
+ 2
objects are instances of classes just like variables of complier defined datatypes
7th Aug 2019, 4:31 PM
Sami
Sami - avatar
+ 2
A ”class” is like the descriptive blueprint of a house. An ”object” is an instance of a class. It is like the actual house itself created using the blueprint. There can only be a single class or blueprint definition. There can be several instances of the class or blueprint. For example, there can be several houses created out of the same design or blueprint.
9th Aug 2019, 4:17 PM
Loreto.E.Torres
Loreto.E.Torres - avatar
+ 1
Any specific language?
7th Aug 2019, 10:41 PM
\•/
\•/ - avatar
+ 1
A class is a human. Human can talk, human can walk... Human has a name, human has two human parents... An object is you, a particular instance of a human. With your name, your parents. And you talk like humans and walk like humans do.
8th Aug 2019, 9:31 AM
Miquel Andreu Fuster Sancho
Miquel Andreu Fuster Sancho - avatar
+ 1
I m giving u a real life example to understand it better. Every thing u see around u is an object while class is the blue print of that object. Example: If u want to build a house, the first thing u will do is to make a map of the house that is the class. Using that map u can build any number of houses. These houses are the objects of that class. 👍
8th Aug 2019, 11:36 AM
Osama Siddique
Osama Siddique - avatar
0
Class is Like schema for house, but object is when you build a house of that schema. You can build many houses with the same schema. Like objects from class.
9th Aug 2019, 7:50 PM
Ahmed Ervin Čajić
Ahmed Ervin Čajić - avatar
0
Sounds like bigbang and creation of universe
10th Aug 2019, 1:09 AM
\•/
\•/ - avatar
0
Objects are instances of classes.to make it clear I'll give you a paradigm assume there is a shirt, There can be different types of shirts based on characteristics so you define a class shirt using different characteristics,then u instantiate objects having different values of characteristics. Eg: class shirt{ char colour[10]; int size; public: getdetail(){.......}; putdetail(){....}; }shirt1,shirt2; Now in above example shirt one and two are objects of a class but one can differ from two in characteristics given.and both belongs to class shirt
17th Aug 2019, 4:54 PM
sameer ganduri
sameer ganduri - avatar
- 1
حاتم علي عوض الجيزاني رقم
8th Aug 2019, 1:38 AM
حاتم الجيزاني
حاتم الجيزاني - avatar