Sail E0 Webinar
Question


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
Options:
A .  10
B .  20
C .  1020
D .  None of the mentioned
Answer: Option C

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 ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers