What is a Class?
The difference between a Class and an object is a source of a lot of confusion for programmers new to the terminology of object-oriented programming. The basic building blocks of object-oriented programming are the class and the object.
In object-oriented programming, a Class is a construct which is defined by a programmer in code and is used as a template (or blueprint) to create objects of that class. This template describes the state and behaviour that the objects of the Class all share.
A class encapsulates the state and behaviour of the concept it represents.
· It encapsulates state through data placeholders called attributes (or member variables);
· It encapsulates behaviour through reusable sections of code called methods.
A class is used to create new instances (Objects) by instantiating the class. An Object doesn't exist until an instance of the class has been created. The class is just a definition.
No comments:
Post a Comment