subject
Computers and Technology, 24.06.2021 21:20 mitch80

Below, suppose that you have the following classes: classA and classB. Write the class into a header that is called from main. Be sure to #include , using namespace std; and any additions such as #include "pch. h" are present. class classA
{
public:
virtual void print() const;
void doubleNum();
classA(int a = 0);
private:
int x;
};
void classA::print() const
{
cout << "ClassA x: " << x << endl;
}
void classA::doubleNum()
{
x = 2 * x;
}
classA::classA(int a)
{
x = a;
}
class classB: public classA
{
public:
void print() const;
void doubleNum();
classB(int a = 0, int b = 0);
private:
int y;
};
void classB::print() const
{
classA::print();
cout << "ClassB y: " << y << endl;
}
void classB::doubleNum()
{
classA::doubleNum();
y = 2 * y;
}
classB::classB(int a, int b) : classA(a)
{
y = b;
}
What is the output of the following function main?
int main()
{
classA *ptrA;
classA objectA(2);
classB objectB(3, 5);
ptrA = &objectA;
ptrA->doubleNum();
ptrA->print();
cout << endl;
ptrA = &objectB;
ptrA ->doubleNum();
ptrA->print();
cout << endl;
return 0;
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 09:00
What provides an array of buttons for quick access to commonly used commands and tools
Answers: 1
question
Computers and Technology, 23.06.2019 12:40
Curriculum exam to process a resident's payment, you must click on onesite payments home page. from the a. reports b. my settings o c.transactions o d. rent tab
Answers: 1
question
Computers and Technology, 24.06.2019 15:00
Universal windows platform is designed for which windows 10 version?
Answers: 1
question
Computers and Technology, 24.06.2019 17:30
Match the following. 1. formatting that is applied when cell data meets certain criteria 2. borders with formats not found on the border tool 3. a shortcut bar that contains tools for commonly used formats 4. formats that can be applied to numbers conditional formatting custom borders format bar number formats
Answers: 3
You know the right answer?
Below, suppose that you have the following classes: classA and classB. Write the class into a header...
Questions
question
Health, 12.01.2021 22:30
question
Spanish, 12.01.2021 22:30
question
Mathematics, 12.01.2021 22:30
question
Mathematics, 12.01.2021 22:30
question
Mathematics, 12.01.2021 22:30
Questions on the website: 13722363