What is Object and Class? What are the differences between
them?

Answer Posted / pankaj vashishta

Class is template for creating similar type of entities.
Class doesn't take memory space untill it contains static
members.
In a specific Class, you declare the attributes(field
variables) and its behaviour(functions).
But Class doesn't have any state and identity.

Objects are the real time entity which are created through
their template, thier class.
By real time entity, I mean they would occupy a memory
space in which they will save the values of its atrributes.
These values create a state of an object.
Since Object occupy a space in memory so they have unique
address in memory. This become the identity of an object.

For example : Pen is a class, which has weight and color as
its attribute. They may have behaviour like write().

Still they don't occupy a space in memory.

When I say My pen ,It will be an object of class Pen since
it will have some values for weight like 10 gm and color
like blue. This will occupy some memory to save these
values.

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the three parts of a simple empty class?

1791


how to get the oracle certification? send me the answer

1928


What is the example of polymorphism?

777


Can we override main method?

874


class CTest { public: void someMethod() { int nCount = 0; cout << "This is some method --> " << nCount; } }; int main() { CTest *pctest; pctest->someMethod(); return 0; } It will executes the someMethod() and displays the value too. how is it possible with our creating memory for the class . i think iam not creating object for the class. Thanks in Advance... Prakash

2019


How to improve object oriented design skills?

784


Why oops is important?

815


hi, this is raju,iam studying b.tech 2nd year,iam want know about group1 and group2 details, and we can studying without going to any instutions? please help me.

1765


What does it mean when someone says I oop?

846


What is overloading in oop?

794


what are the realtime excercises in C++?

2581


What causes polymorphism?

858


What is cohesion in oop?

866


What is constructor in oop?

852


How do you achieve polymorphism?

856