Question
1.
#include
2.
using namespace std;
3.
class BaseClass
4.
{
5.
int x;
6.
public:
7.
void setx(int n)
8.
{
9.
x = n;
10.
}
11.
void showx()
12.
{
13.
cout
What is the output of this program?
1.
#include
2.
using namespace std;
3.
class BaseClass
4.
{
5.
int x;
6.
public:
7.
void setx(int n)
8.
{
9.
x = n;
10.
}
11.
void showx()
12.
{
13.
cout
Answer: Option C
Was this answer helpful ?
In this program, We are passing the values from the main class and printing it on the inherited classes.
Output:
$ g++ des2.cpp
$ a.out
1020
Was this answer helpful ?
Submit Solution