subject
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;
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 06:00
Which statement is true of web-based social media? a.they allow consumers to interact with and update content. b.they cannot be updated easily, as compared to print media. c.they are expensive to produce and maintain, as compared to print and television. d.they can exist independent of the internet.
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
1. which of the following statements are true about routers and routing on the internet. choose two answers. a. protocols ensure that a single path between two computers is established before sending packets over it. b. routers are hierarchical and the "root" router is responsible for communicating to sub-routers the best paths for them to route internet traffic. c. a packet traveling between two computers on the internet may be rerouted many times along the way or even lost or "dropped". d. routers act independently and route packets as they see fit.
Answers: 2
question
Computers and Technology, 24.06.2019 15:40
In the above figure, what type of cylinder arrangement is shown in the figure above? a. l-type b. v-type c. in-line d. horizontal pls make sure its right if its rong im grounded for 3months
Answers: 1
question
Computers and Technology, 25.06.2019 00:00
Rom is designed for computer instructions temporary storage of data processing data
Answers: 1
You know the right answer?
What is the output of the following C++ program?

#include
#include

...
Questions
Questions on the website: 13722367