If the derived class classD overrides a public member function functionName of the base class classB, then to specify a call to that public member function of the base class, you use the statement __________.a. classD::functionName();b. classB::functionName();c. classD.functionName();d. classB.functionName();

Respuesta :

Answer:

Option (d)

Explanation:

More specifically class B's object name will be there which would be

obj.funcname();

where obj is object of class B. If we need to call overridden method of class D then object of class D should be made. For example :

#include <iostream>

using namespace std;

class B

{

   public:

   void print()

   {

       cout<<"class B";

   }

};

class D : public B

{

   public:

   void print()

   {

       cout<<"class D";

   }

};

int main()

{

   B obj;

   obj.print();  //option d

   return 0;

}

Options a and b are wrong as it is no way of calling a class's method and option c would call the overridden method of derived class.

ACCESS MORE
EDU ACCESS