What will the following
#include <iostream>
using namespace std;
class First
{
protected:
int a:
public:
First(int x = 1)
{ a = x; }
virtual void twist()
{ a * = 2; }
int getVal ()
{ twist(); return a; }
}:
class Second : public First
{
private:
int b:
public:
Second(int y = 5)
{ b = y; }
virtual void twist()
{ b *= 10: }
};
int main()
{
First object-1;
Second object2;
cout ≪ object1.getVal () ≪ endl;
cout ≪ object2.getVal() ≪ endl;
return 0;
Want to see the full answer?
Check out a sample textbook solutionChapter 15 Solutions
Starting Out with C++ from Control Structures to Objects, Student Value Edition (9th Edition)
Additional Engineering Textbook Solutions
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Starting Out With Visual Basic (8th Edition)
Starting out with Visual C# (4th Edition)
Starting Out with Python (4th Edition)
C How to Program (8th Edition)
Starting Out with Java: Early Objects (6th Edition)
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education