Templates
- Which value is placed in the base class?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
We can place the default type values in a base class and overriding some of them through derivation.
- Which is dependant on template parameter?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
base class
- What is another name of full specialization?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
explicit specialization
- How many types of specialization are there in c++?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
There are two types of specialization. They are full specialization and partial specialization.
- What is the output of this program?
#include <iostream>
using namespace std;
template<class T = float, int k = 5> class N
{
public:
N();
int value;
};
template<> class N<>
{
public: N();
};
template<> class N<double, 10>
{
public: N();
};
template<class T, int k> N<T, k>::N() : value(k)
{
cout << value;
}
N<>::N()
{
cout << " Out of ";
}
N<double, 10>::N()
{
cout << "10" << endl;
}
int main()
{
N<int, 8> x;
N<> y;
N<double, 10> z;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
In this program, We are defining three templates and specializing it and passing the values to it and printing it.