Computer Science - Object Oriented Programming Using C++ - Discussion
Discussion Forum : Object Oriented Programming Using C++ - Section 3 (Q.No. 8)
8.
When a class is derived from another derived class, the newly derived class
Discussion:
2 comments Page 1 of 1.
Ravi said:
9 years ago
The Answer is 'C' and NOT 'D' because.
Let us have one base class (parent) from which we can have derived class (child). Now again, according to statement given, the existing child class will become parent when we create child class of this child class. Let us look it this way, grand parent, parent and child.
Now the protected members of grandparent class can be used only by parent class and cannot be used by child class. However, the protected members of parent class can be used by its child class.
So, answer is 'C'.
Hope This explanation is simple enough.
Let us have one base class (parent) from which we can have derived class (child). Now again, according to statement given, the existing child class will become parent when we create child class of this child class. Let us look it this way, grand parent, parent and child.
Now the protected members of grandparent class can be used only by parent class and cannot be used by child class. However, the protected members of parent class can be used by its child class.
So, answer is 'C'.
Hope This explanation is simple enough.
Bedant said:
9 years ago
Why answer is not D?. Because if there is no private or protected member in the base class, then newly derived class and the immediate predecessor will have same access to base class.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers