Question: This program is in C++ Determine whether the following code is correct or not. If NOT, then correct it. #include using namespace std; class baseA
This program is in C++
Determine whether the following code is correct or not. If NOT, then correct it.
#include
using namespace std;
class baseA { private: int value; public: baseA() { cout <<" enter a number : "; cin >> value; } };
class derivedB : protected baseA { public: void display() { ++value; cout <<" value in derivedB = " << value << endl; } };
class derivedC : public derivedB { public: void display() { ++value; cout <<" value in derivedC = " << value << endl; } };
int main() { derivedC objC; objC.display(); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
