Accessing base class method using derived class object

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



#include<iostream>
using namespace std;

class A
{
public:
void display()
{
cout<<"A display"<<endl;
}

};

class B : public A
{
public:
void display()
{
cout<<" B display "<<endl;
}
};

int main()
{
B b1;
b1.display();

return 0;
}

In this program can you please tell me how can i access base class
method ie.,display() using derived class object.ie.,b1.

A single line has to be included in this main funtion.

.



Relevant Pages