Ask Question
10 April, 19:18

Consider the following base and derived class declarations: class BaseClass { public: void BaseAlpha (); private: void BaseBeta (); float baseField; }; class DerivedClass : public BaseClass { public: void DerivedAlpha (); void DerivedBeta (); private: int derivedField; }; For each class, do the following:

a) List all private data members.

b) List all private data members that the class's member functions can reference directly.

c) List all functions that the class's member functions can invoke.

d) List all member functions that a client of the class may invoke.

+3
Answers (1)
  1. 10 April, 21:23
    0
    a) Baseclass - baseField

    DerivedClass - derivedField

    b) BaseClass - baseField

    DerivedClass - derivedField

    c) BaseClass - BaseBeta (), BaseAlpha ()

    DerivedClass - BaseAlpha (), DerivedAlpha (), DerivedBeta ()

    d) BaseClass - BaseAlpha ()

    DerivedClass - BaseAlpha (), DerivedAlpha (), DerivedBeta ()

    Explanation:

    a) Since, private members of a class cannot be inherited, that is why, DerivedClass has only one private data member.

    b) Member function of a class can invoke private data variables of the class, so, they can refer to their private members on their own but DerivedClass has no access to BaseClass's private members.

    c) Every member function of a class can invoke every other member function of that class, but DerivedClass's member function cannot invoke BaseClass's private member functions.

    d) Object of a class has no access to private members of a class, that is why they can invoke only public member functions of the class.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Consider the following base and derived class declarations: class BaseClass { public: void BaseAlpha (); private: void BaseBeta (); float ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers