In: Computer Science
Answer the questions related to the following code:
Class B
{
Public:
Void b1();
Protected:
Void b2();
};
Class A : public B
{
Public:
Void a1();
Protected:
Void a2();
};
Class C: public A
{
Public:
Void c1();
};
Void main ()
{
B temp1; A temp2; C temp3;
}
a. The member function visible through temp1 in the main function is b1().
b2() is protected, so it is not visible in main(). All other functions belong to other classes. They cannot be accessed using temp1.
Therefore, b1() is the only member function which is visible through temp1 in the main function.
b. The member functions visible through temp2 in the main function are b1() and a1().
b2() and a2() are protected, so they cannot be accessed in the main.
c1() is the member function of its child class. It cannot be accessed too.
Therefore, b1() and a1() are the member functions which are visible through temp2 in the main function.
c. The member functions visible through temp3 in the main function are b1(), a1() and c1().
b2() and a2() are protected. So, they cannot be accessed in the main.
Therefore, the functions b1(), a1() and c1() are the member functions which are visible through temp3 in the main function.
d. Class B is the parent class of A.
e. Class C is the child class of A.