Ask Question
13 March, 12:17

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.

+1
Answers (1)
  1. 13 March, 14:59
    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?
Find an answer to your question ✅ “Consider the following base and derived class declarations: class BaseClass { public: void BaseAlpha (); private: void BaseBeta (); float ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers