Loading....
Coupon Accepted Successfully!

 

Access Specifiers and Their Scope

As described in Table, the class object can access a public member of the class directly without the use of member function. The private and protected mechanisms do not allow an object to access data directly. The object can access private or protected members only through public member functions of the same class.

Table: Access Limits of class Members

 

Access Specifiers

Access Permission

class Members

class Object

Public

Allowed

Allowed

Private

Allowed

Disallowed

Protected

Allowed

Disallowed


The following program explains the working of the above keywords:


8.5 Write a program using class to declare member variable and functions private, public and protected section and make an attempt to access them using object.

 





Test Your Skills Now!
Take a Quiz now
Reviewer Name