What is the output of the following C++ program?
#include
#include
...
Computers and Technology, 04.04.2020 14:22 theo39
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;
}
Answers: 2
Computers and Technology, 22.06.2019 19:30
When using a public computer or network, you should always
Answers: 2
Computers and Technology, 23.06.2019 07:00
Why were most movies from the late 1890s until the early 1930s only filmed in black and white? there were only a few people who could afford the technology to produce color motion pictures back then. audiences did not want color motion pictures until later. the film used to make color motion pictures often overheated, which was a safety hazard, so it was generally not allowed. color films had to be hand-colored, frame by frame.
Answers: 3
Computers and Technology, 23.06.2019 15:00
Visually impaired individuals generally rely on the for navigation. thus, designers need to ensure that mouse-specific inputs, such as pointing, clicking, and hovering, can be done without a mouse.
Answers: 1
Computers and Technology, 24.06.2019 06:50
What are the things you are considering before uploading photos on social media?
Answers: 1
Physics, 18.07.2019 22:30
Mathematics, 18.07.2019 22:30
Biology, 18.07.2019 22:30
Biology, 18.07.2019 22:30
English, 18.07.2019 22:30
Physics, 18.07.2019 22:30
English, 18.07.2019 22:30
Mathematics, 18.07.2019 22:30
Mathematics, 18.07.2019 22:30
Mathematics, 18.07.2019 22:30