What is class?

Class is a collection of similar types of objects, where each class having similar properties and types.
Ex: Bird, Animal

Need of class and object
Class supports data encapsulation and data abstraction which leads C++ a more secure programming language. Apart from these features, the class also has private and public section, where we put the very important data in private section and comparatively less important data in public section. These two are known as access specifiers.

Features of OOPS
The main features of OOP are class, object, data hiding and encapsulation, inheritance, polymorphism and message passing.

Class and Object
Class is a collection of similar types of objects. For example if college, school, institutions are three objects then, combinly the three objects form a class and the class name is Education.
Ex2: If elephants, tigers, lions and cats will be considered as objects then the class for these object will be Animal.

You can consider the class and object name as per your wish and always keep in mind that these objects are formed from the class. So class is imagined as a whole and objects are part of it.

Data hiding
Putting the data in private section can only be accessed by using object and the function associated with it. This feature of OOP is known as data hiding.

Encapsulation
Wrapping around data and functions inside a class is known as encapsulation. This feature makes program easy to understand.

Inheritance
The code reusabilty features for programming which is also known as inheritance. So inheritance is the property by which one class can get the properties of another class.

Polymorphism
Poly means many and morphism means form. It’s a greek word whose meaning is one name multiple form. This feature allows to write same name for functions and operators but the meaning for each one varies in different places. Its of two type i.e. run type polymorpism and compile time polymorphism.

Dynamic binding
Asociating function call during program execuation is known as dynamic binding.

Message passing
Objects communicates with each other through message is known as message passing. Data is transferred from one object to another through object and functions.

Note: Most frequently variables are put in private sections because these are very sensitive
data for the real world purpose. Generally functions are put in public section which are mainly used for accessing these private data.

Share with : Share on Linkedin Share on Twitter Share on WhatsApp Share on Facebook