-
What is the output of this program?
#include <iostream>
using namespace std;
class BaseClass
{
int A;
public:
void setA(int num1)
{
A = num1;
}
void showA()
{
cout << A <<" ";
}
};
class DerivedClass : private BaseClass
{
int B;
public:
void setAB(int num1, int num2)
{
setA(num1);
B = num2;
}
void showAB()
{
showA();
cout << B << '\n';
}
};
int main()
{
DerivedClass object;
object.setAB(15, 25);
object.showAB();
return 0;
}
-
- 15
- 25
- 25 15
- 15 25
- None of these
Correct Option: D
In this program, We are passing the values from the main class and printing it on the inherited classes.