Class and Objects in Object-Oriented Programming
Class and Object Definitions
Class: A user-defined derive data type that combines data and its association function together into a single unit.
Object: An instance variable of a class. Once a class is created, any number of objects can be declared.
Advantages and Need of Using Class
Represents Real World Entities: Classes represent real-world entities, containing data types as well as working with related functions.
Supports OOP's Concepts: Supports concepts such as abstraction, incamsulation, inheritance, and data hiding.
Syntax for Creating Class
Declaration Structure:
class Class_name
{
private:
Data members Declaration;
Member Function Declaration;
public:
DMD;
MFD;
protected:
DMD;
MFD;
};
Components of a Class
Class Tag Name: Defines the name of a class whose object is to be created.
Data Member: Members of a class that describe the characteristics of the class. A class may contain no data members or any number of data members in any part.