Question: In several object-oriented languages, including C++ and Eiffel, a derived class can hide members of the base class. In C++, for example, we can declare

In several object-oriented languages, including C++ and Eiffel, a derived class can hide members of the base class. In C++, for example, we can declare a base class to be public, protected, or private:

class B : public A {... // public members of A are public members of B // protected members of A are protected members of B ... class C : protected A {... // public and protected members of A are protected members of C ... class D : private

In all cases, private members of A are inaccessible to methods of B, C, or D. Consider the impact of protected and private base classes on dynamic method binding. Under what circumstances can a reference to an object of class B, C, or D be assigned into a variable of type A*?

class B : public A {... // public members of A are public members of B // protected members of A are protected members of B ... class C : protected A {... // public and protected members of A are protected members of C ... class D : private A { ... // public and protected members of A are private members of D

Step by Step Solution

3.35 Rating (167 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

class B public A anybody can convert assign a B into ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Language Pragmatics Questions!