Dương Mạnh Cường
New member
What will be the output of the following C++ code?
A.
2
1
B.
1
2
C.
1
1
D.
2
2
Code:
#include <iostream>
using namespace std;
template <class T>
class Test
{
private:
T val;
public:
static int count;
Test() {
count++;
}
};
template<class T>
int Test<T>::count = 0;
int main()
{
Test<int> a;
Test<int> b;
Test<double> c;
cout << Test<int>::count << endl;
cout << Test<double>::count << endl;
return 0;
}
2
1
B.
1
2
C.
1
1
D.
2
2