Subscribe

Header Ads

Objects and Classes


Object:

  • It is the basic run-time entity of object-oriented programming.
  • You can define it as the set of properties and operations performed by using an entity`s property set is known as an object.
  • It is the collection of data members and associated member functions

Class:

  • Class is the description of the contents of the objects that belongs to it.
  • It is a user-defined data type that is defined by using the keyword "class".
  • It is the collection of data members and member functions.
  • Data members and member functions accessed by 2 accessed specifiers are: private, protected, and public.
  • By default, the class has private access specifier.

Private: 

When the data is defined in a class privately then it can be accessed only in that class or by the member functions of that class.
It can not be inherited by another class.

Protected:

When the data is defined in a class as protected then it can be inherited by other classes.
It can only be accessed within the class in which it had defined and in the friend classes.

Public:

When the data is defined in a class as public then it can be accessed within the class as well as outside the class.

For Example:
.
.
.
Class emp
{
    ......
};
.
.
int main()
{
    emp E1;
}

Here emp is the class and E1 is the object of emp.

Post a Comment

0 Comments