Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by whitelisting our website.

Cpp Programming Quiz 101 – What will be the output of the following program?

Question: What will be the output of the following program?

#include
class A
{
public:
void BixFunction(void)
{
cout<< "Class A" << endl; } }; class B: public A { public: void BixFunction(void) { cout<< "Class B" << endl; } }; class C : public B { public: void BixFunction(void) { cout<< "Class C" << endl; } }; int main() { A *ptr; B objB; ptr = &objB; ptr = new C(); ptr->BixFunction();
return 0;
}

[A].Class A.
[B].Class B.
[C].Class C.
[D].The program will report compile time error.

Answer: Option A