Examveda

What will be the output of the following C++ code?
#include <iostream>
using namespace std;
template<class T = float, int i = 5> class A
{
    public:
    A();
    int value;
};
template<> class A<> 
{ 
    public: A(); 
};
template<> class A<double, 10>
{ 
    public: A(); 
};
template<class T, int i> A<T, i>::A() : value(i)
{
    cout << value;
}
A<>::A() 
{
    cout << "default";
}
A<double, 10>::A() 
{
    cout << "10" << endl;
}
int main() 
{
    A<int, 6> x;
    A<> y;
    A<double, 10> z;
}

A. 6

B. 10

C. 6default10

D. 6default

Answer: Option C


Join The Discussion

Related Questions on C plus plus miscellaneous

What is the difference between '++i' and 'i++' in C++?

A. None of the above

B. They both have the same effect

C. '++i' increments the value of 'i' before returning it, while 'i++' increments the value of 'i' after returning it

D. '++i' increments the value of 'i' after returning it, while 'i++' increments the value of 'i' before returning it