Examveda

What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class sample
{
    public:
    virtual void example() = 0; 
};
class Ex1:public sample
{
    public:
    void example()
    {
        cout << "ubuntu";
    }
};
class Ex2:public sample
{
    public:
    void example()
    {
        cout << " is awesome";
    }
};
int main()
{
    sample* arra[2];
    Ex1 e1;
    Ex2 e2;
    arra[0]=&e1;
    arra[1]=&e2;
    arra[0]->example();
    arra[1]->example();
}

A. ubuntu

B. is awesome

C. ubuntu is awesome

D. ubunt esome

Answer: Option C


Join The Discussion

Related Questions on C plus plus miscellaneous

What is the difference between '++i' and 'i++' in C++?

A. None of the above

B. They both have the same effect

C. '++i' increments the value of 'i' before returning it, while 'i++' increments the value of 'i' after returning it

D. '++i' increments the value of 'i' after returning it, while 'i++' increments the value of 'i' before returning it