Answer to Question #234716 in C++ for SOM

Question #234716

Complete the given code to get the output shown below:-

Base1

Base2


#include<iostream>

using namespace std;

class Base1 {

 public:

     void display()

     { cout << " Base1"<< endl; }  };

class Base2 {

public:

    void display()

     { cout << "Base2"<<endl"; } };

class Derived: public Base1, public Base2 {

   public:

 };

int main()

{

   Derived d;

   return 0;



1
Expert's answer
2021-09-11T07:01:37-0400
#include<iostream>


using namespace std;


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


class Base2 {


public:


	void display(){ 
		cout << "Base2"<<endl; 
	} 


};


class Derived: public Base1, public Base2 {


public:
	Derived(){ 
		Base1::display(); 
		Base2::display(); 
	} 
};


int main(){


	Derived d;




	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