/*
State the Output
*/
#include<iostream>
using namespace std;
class base
{
public:
int n1;
void show()
{
cout<<"\n n1: "<<n1;
}
};
class Derived:public base
{
public:
int n2;
void show()
{
cout<<"\n n1: "<<n1;
cout<<"\n n2: "<<n2;
}
};
int main()
{
base b;
base *bptr;
cout<<"\n\n Pointer of base class points to it: ";
bptr=&b;
bptr->n1=44;
bptr->show();
Derived d;
bptr=&d;
bptr->n1=66;
bptr->show();
return 0;
}
State the Output
*/
#include<iostream>
using namespace std;
class base
{
public:
int n1;
void show()
{
cout<<"\n n1: "<<n1;
}
};
class Derived:public base
{
public:
int n2;
void show()
{
cout<<"\n n1: "<<n1;
cout<<"\n n2: "<<n2;
}
};
int main()
{
base b;
base *bptr;
cout<<"\n\n Pointer of base class points to it: ";
bptr=&b;
bptr->n1=44;
bptr->show();
Derived d;
bptr=&d;
bptr->n1=66;
bptr->show();
return 0;
}