← Back to Question List
C++ Quiz #128
One Counter per Specialization
Each Counter<T> has a static member made that its constructor increments. Three objects are created. What is printed?
📄 Code
1#include <iostream>23template <typename T>4class Counter {5public:6 static int made;7 Counter() { made++; }8};910template <typename T>11int Counter<T>::made = 0;1213int main() {14 Counter<int> a;15 Counter<double> b;16 Counter<int> c;17 std::cout << Counter<int>::made << " " << Counter<double>::made << "\n";18 return 0;19}