Question
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
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
Answer: Option B
Was this answer helpful ?
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