-
What is the output of this program?
#include <iostream>
using namespace std;
class FirstClass
{
int m;
public:
FirstClass() : m(12)
{
}
FirstClass(int mm): m(mm)
{
}
int getm()
{
return m;
}
};
class SecondClass : public FirstClass
{
int n;
public:
SecondClass(int nn) : n(nn) {}
int getn() { return n; }
};
int main()
{
SecondClass object(105);
cout << object.getm() << " " << object.getn() << endl;
}
-
- 12
- 105
- 105 12
- 12 105
- None of these
Correct Option: D
In this program, We are passing the value and getting the result by derived class.