Answer to Question #234712 in C++ for SOM

Question #234712

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-09T17:12:00-0400
#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(){ this->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