State the Output Pointer to derived class 3

/*
    State the Output
*/
#include<iostream>
using namespace std;

class base
{
    public:
            void show()
            {
                cout<<"\n Base";
            }
};

class Derived:public base
{
    public:
            void show()
            {
                cout<<"\n Derived";
            }
};

int main()
{
    base b1;
    b1.show();

    Derived d1;
    d1.show();

    base *pb=&b1;
    pb->show();

    pb=&d1;

    pb->show();

    return 0;
}

Previous
Next Post »