-
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;
}
-
- 10 out of 8
- 8
- 10
- 8 out of 10
- None of these
Correct Option: D
In this program, We are defining three templates and specializing it and passing the values to it and printing it.