adplus-dvertising
frame-decoration

Question

Which among the following is true for the code given below:a) Only object of class A can access disp() function
class A
{
 int marks;
 public : disp()
 { 
  cout<<marks; 
 }
}
class B: protected A
{
 char name[20];
}
A a; a.disp();
B b; b.disp();

a.

Only object of class A can access disp() function

b.

Only object of class B can access disp() function

c.

Both instances can access disp() function

d.

Accessing disp() outside class is not possible

Answer: (a).Only object of class A can access disp() function

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Which among the following is true for the code given below:a) Only object of class A can access disp() function