26.9k views
5 votes
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();

User Fenkerbb
by
6.4k points

1 Answer

1 vote

Answer:

Option (d)

Step-by-step 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.

User Velcrow
by
6.2k points