Answer to Question #239535 in C++ for world

Question #239535

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;

}


1
Expert's answer
2021-09-23T00:58:12-0400
#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;


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS