OOPS
August 29, 2024OOPS
August 29, 2024OOPS
|
Question 128
|
Which of the following is not true in case of public inheritance in c++?
|
Each public member in the base class is public in the derived class
|
|
|
Each protected member in the base class is protected in the derived class
|
|
|
Each private member in the base class remains private in the base class
|
|
|
Each private member in the base class remains private in the derived class
|
Question 128 Explanation:
→ Public Inheritance − When deriving a class from a public base class, public members of the base class become public members of the derived class and protected members of the base class become protected members of the derived class.
→ A base class’s private members are never accessible directly from a derived class, but can be accessed through calls to the public and protected members of the base class.
We can summarize the different access types according to – who can access them in the following way −
→ A base class’s private members are never accessible directly from a derived class, but can be accessed through calls to the public and protected members of the base class.
We can summarize the different access types according to – who can access them in the following way −
Correct Answer: D
Question 128 Explanation:
→ Public Inheritance − When deriving a class from a public base class, public members of the base class become public members of the derived class and protected members of the base class become protected members of the derived class.
→ A base class’s private members are never accessible directly from a derived class, but can be accessed through calls to the public and protected members of the base class.
We can summarize the different access types according to – who can access them in the following way −
→ A base class’s private members are never accessible directly from a derived class, but can be accessed through calls to the public and protected members of the base class.
We can summarize the different access types according to – who can access them in the following way −
