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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!