C++ Programming - OOPS Concepts - Discussion
Discussion Forum : OOPS Concepts - General Questions (Q.No. 39)
39.
Which of the following are available only in the class hierarchy chain?
Discussion:
13 comments Page 2 of 2.
Rahul Shirsat said:
1 decade ago
It is so because.
In a hierarchy, there are several classes inheriting their respective parents.
First of all, protected member means : they can be accessible only by the class which is inheriting it. Father's own Child can only access the protected members of Father and not the cousins, neighbors or any other.
Take a simple example.
GA is grand-parent of A and GB is grand-parent of B resp.
Only A should know secret password of GA. So as B to GB. :) :).
In a hierarchy, there are several classes inheriting their respective parents.
First of all, protected member means : they can be accessible only by the class which is inheriting it. Father's own Child can only access the protected members of Father and not the cousins, neighbors or any other.
Take a simple example.
GA is grand-parent of A and GB is grand-parent of B resp.
Only A should know secret password of GA. So as B to GB. :) :).
Cherry said:
1 decade ago
@protected data members are available by default throughout the class hierarchy chain.
i.e., we are using the keyword protected before the data members of class.
And remaining data members of class available based on their visibility (either public or private).
i.e., we are using the keyword protected before the data members of class.
And remaining data members of class available based on their visibility (either public or private).
SHILPA said:
1 decade ago
Can anybody explain why?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers