-
What is the output of this program?
#include <iostream>
using namespace std;
class Base
{
int K;
public:
void setInt(int num);
int getInt();
};
class Derived : public Base
{
int L;
public:
void setL(int num);
int multiply();
};
void Base::setInt(int num)
{
K = num;
}
int Base::getInt()
{
return K;
}
void Derived::setL(int num)
{
L = num;
}
int Derived::multiply()
{
return L * getInt();
}
int main()
{
Derived object;
object.setInt(12);
object.setL(3);
cout << object.multiply();
return 0;
}
-
- 36
- 12
- 3
- All of above
- None of these
Correct Option: A
In this program, We are multiplying the value 12 and 3 by using inheritance.