Assume a class Derv that is privately derived from class Base. An object of class Derv located in main() can access

public members of Base
protected members of Base
private members of Base
public members of Derv

The correct answer is: B. protected members of Base

A private member of a class is not accessible to any code outside of that class. However, a protected member of a class is accessible to code within that class and to code within any class that is derived from that class.

In this case, class Derv is privately derived from class Base. This means that an object of class Derv can access the protected members of class Base.

The public members of class Derv are accessible to any code, regardless of whether it is within class Derv or not.

The private members of class Derv are not accessible to any code, regardless of whether it is within class Derv or not.

Exit mobile version