0

What is the difference between a class and an object?

oop

8/18/2019 4:03:44 PM

Ахан

7 Answers

New Answer

+3

Ахан What you do not understand? What is a point of confusion? If you were to manufacture the body/frame of your smartphone, what do you need? A design diagram of the frame, telling how it would look, with details like where to put notches/locks, hole etc for heat ventilation etc. Based on this diagram you will prepare a mould or a die, which will then be used to make actual smartphone frames. These frames are your objects and the design along with the mould/die is your class. All frames created from the die have same properties, same features, shape etc. Some of the properties can be changed when creating objects, like you may want change the color, the type of material used etc. Classes are blueprints, on their own are useless. Objects are alive and participate in various type of activities. C++ eg. class ABC { private: int color; int length; public: ABC(int color, int length): :this->color(color), this->length(l }; ABC is a class that define two properties color and length ABC abc(red, 10); abc is an object a live thing which has a specific color and specific length.

+1

A object is an instance of a class. Have a look at SoloLearns Tutorial about java, this will help you. :) A class can be seen as a building plan for an object. For example you describe some parameters and methods in a class. To use this class you have to create an instance of this class, a so called object.

+1

I often wonder what is the root cause of this confusion. Why people get confused while trying to understand this fundamental concept. Should this concept be taught in a different way to avoid this confusion. And what would be that different way.

+1

Swim, Thanks

+1

Ахан 👍🙂

0

can somehow explain in a particular language?

0

show an example?