Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Find Output. Just output. No explanation needed.. #include #include using namespace std; class baseClass { public: void print() const; baseClass(string s = , int

Find Output. Just output. No explanation needed..

#include #include

using namespace std;

class baseClass { public: void print() const; baseClass(string s = " ", int a = 0); //Postcondition: str = s; x = a;

protected: int x;

private: string str; };

class derivedClass: public baseClass { public: void print() const; derivedClass(string s = "", int a = 0, int b = 0); //Postcondition: str = s; x = a; y = b; private: int y; };

int main() { baseClass baseObject("This is the base class", 2); derivedClass derivedObject("DDDDDD", 3, 7);

baseObject.print(); derivedObject.print();

system("pause");

return 0; } void baseClass::print() const { cout << x << " " << str << endl; }

baseClass::baseClass(string s, int a) { str = s; x = a; }

void derivedClass::print() const { cout << "Derived class: " << y << endl; baseClass::print(); }

derivedClass::derivedClass(string s, int a, int b) : baseClass("Hello Base", a + b) { y = b; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

More Books

Students also viewed these Databases questions

Question

Derive Eq. (17.33) and Eq. (17.34).

Answered: 1 week ago

Question

What reward policy would you suggest to the university?

Answered: 1 week ago