Include the function calls at appropriate places in the given program, to get the
output as shown below
In base
In derived
#include<iostream>
using namespace std;
class base
{ int b;
protected:
void display(){cout<<"In base\n";}
};
class derived:public base
{ int d;
public:
void display(){ cout<<"In derived\n";}
};
int main()
{ derived D;
return 0;
}
#include<iostream>
using namespace std;
class base
{
int b;
protected:
void display(){
cout<<"In base\n";
}
public:
void base_display(){
display();
}
};
class derived: public base
{
int d;
public:
void display(){
base_display();
cout<<"In derived\n";
}
};
int main()
{
derived D;
D.display();
return 0;
}
Comments
Leave a comment