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, 21.06.2019 22:00
Signal sets company contracts to deliver one hundred 52-inch plasma high-definition television sets to a new retail customer, tuner tv store, on may 1, with payment to be made on delivery. signal tenders delivery in its own truck. tuner's manager notices that some of the cartons have scrape marks. tuner's owner phones signal's office and asks whether the sets might have been damaged as they were being loaded. signal assures tuner that the sets are in perfect condition. tuner tenders signal a check, which signal refuses, claiming that the first delivery to new customers is always for cash. tuner promises to pay the cash within two days. signal leaves the sets with tuner, which stores them in its warehouse pending its "grand opening sale" on may 15. two days later, tuner's stocker opens some of the cartons and discovers that a number of the sets are damaged beyond ordinary repair. signal claims tuner has accepted the sets and is in breach by not paying on delivery. will signal succeed on these claims? explain.
Answers: 1
question
Computers and Technology, 22.06.2019 16:30
Which of the following statements best describes it careers?
Answers: 2
question
Computers and Technology, 22.06.2019 22:30
Which of the following factors would your hypothetical supervisor look at when deciding whether to test a biological material sample for dna? the amount of other evidence you have implicating a suspect in a crime the annual budget for the crime lab both of the above none of the above; you would almost always order a test
Answers: 3
question
Computers and Technology, 22.06.2019 23:20
How can you tell if someone sent you a text message to your email instead of a email
Answers: 1
You know the right answer?
What is the output of the following C++ program?

#include
#include

u...
Questions
question
SAT, 22.05.2021 23:00
question
Mathematics, 22.05.2021 23:00
question
Mathematics, 22.05.2021 23:00
question
Mathematics, 22.05.2021 23:00
question
Mathematics, 22.05.2021 23:00
Questions on the website: 13722363