What is the output of the following C++ program?
#include
#include
u...
Computers and Technology, 19.03.2020 21:44 dantew8238
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: 3
Computers and Technology, 23.06.2019 00:00
How do we use the sumif formula (when dealing with different formats) ?
Answers: 1
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
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
Computers and Technology, 24.06.2019 06:50
What are the things you are considering before uploading photos on social media?
Answers: 1
Mathematics, 04.03.2021 18:00
Mathematics, 04.03.2021 18:00
English, 04.03.2021 18:00
Mathematics, 04.03.2021 18:00
Arts, 04.03.2021 18:00
Chemistry, 04.03.2021 18:00
Geography, 04.03.2021 18:00
Mathematics, 04.03.2021 18:00
Computers and Technology, 04.03.2021 18:00
Advanced Placement (AP), 04.03.2021 18:00
History, 04.03.2021 18:00
History, 04.03.2021 18:00