+ 3

Every Object has an identity, attribute and Behaviour. Attribute and Behaviour for an object is given by a Class.

2nd Mar 2017, 1:38 PM
Akash Singh
Akash Singh - avatar
6 Réponses
+ 1
Yes you are right. Take the example written below Class Person { int age; string name; void function() {.....} }; When u create a person object in main() it has its own identity in the memory which tells that the object is of class type person. Attributes from the above snippet: age, name. behavior : function(method) that u implement inside the class.
2nd Mar 2017, 5:00 PM
Satyendra yadav
Satyendra yadav - avatar
+ 1
Thanks for elaborating 😇 and i guess identity is derived from the values given to the attributes
2nd Mar 2017, 5:02 PM
Akash Singh
Akash Singh - avatar
0
Object identity tells about the class it belongs to.
2nd Mar 2017, 5:35 PM
Satyendra yadav
Satyendra yadav - avatar
0
Then how can different objects vary and have their unique identity in a same class itself 🤔
2nd Mar 2017, 5:37 PM
Akash Singh
Akash Singh - avatar
0
For example u create an object name Akash which contains the attributes defining ur age and name. Now if I create an object satyendra then it contains the age and name of mine.Object Akash will be different from object satyendra. They both have different identities.
2nd Mar 2017, 5:44 PM
Satyendra yadav
Satyendra yadav - avatar
0
Hi.
2nd Mar 2017, 6:26 PM
Olga Memleloum