What will the following
#include <iostream.>
using namespace std;
class First
{
protected:
int a;
public:
First(int x = 1)
{ a = x; }
void twist()
{ a *= 2; }
int getVal()
{ twist(); return a; }
}:
class Second : public First
{
private:
int b;
public:
Second(int y = 5)
{ b = y; }
void twist()
{ b *= 10: }
}:
int main()
{
First object1;
Second object2;
cout ≪ object1.getVa˥ ()≪ end˥
cout ≪ object2.getVa˥ ()≪ end˥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 (9th Edition)
Additional Engineering Textbook Solutions
Starting Out with C++: Early Objects (9th Edition)
Software Engineering (10th Edition)
Modern Database Management (12th Edition)
Database Concepts (7th Edition)
Java: An Introduction to Problem Solving and Programming (7th 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