Sail E0 Webinar
Question


What is the output of this program?


1..
#include
2.
using namespace std;
3.
template
4.
class A
5.
{
6.
public:
7.
A(int a): x(a) {}
8.
protected:
9.
int x;
10.
};
11.
template
12.
class B: public A
13.
{
14.
public:
15.
B(): A::A(100)
16.
{
17.
cout
Options:
A .  100
B .  200
C .  error
D .  runtime error
Answer: Option B

In this program, We are passing the values and manipulating it by using the template inheritance.
Output:
$ g++ dert2.cpp
$ a.out
200



Was this answer helpful ?

Submit Solution

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

Latest Videos

Latest Test Papers