subject

What is the output of the following C++ program?

#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("", 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;
}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 00:00
How do we use the sumif formula (when dealing with different formats) ?
Answers: 1
question
Computers and Technology, 23.06.2019 06:30
You are consulting for a beverage distributor who is interested in determining the benefits it could achieve from implementing new information systems. what will you advise as the first step?
Answers: 1
question
Computers and Technology, 24.06.2019 01:30
Suppose a cpu with a write-through, write-allocate cache achieves a cpi of 2. what are the read and write bandwidths (measured by bytes per cycle) between ram and the cache? (assume each miss generates a request for one block.)
Answers: 1
question
Computers and Technology, 24.06.2019 06:50
What are the things you are considering before uploading photos on social media?
Answers: 1
You know the right answer?
What is the output of the following C++ program?

#include
#include

u...
Questions
question
Mathematics, 04.03.2021 18:00
question
Arts, 04.03.2021 18:00
question
Geography, 04.03.2021 18:00
question
Advanced Placement (AP), 04.03.2021 18:00
Questions on the website: 13722360