Count Constructions per Template Type
Count Constructions per Template Type
Complete the class template CounterBox<T> so that it counts how many objects of EACH specialization have been constructed:
- a private static int created
- the constructor adds 1 to created
- static int getCreated() returns it
- define the static member outside the class with the template prefix, starting at 0
A static member belongs to the class, and every specialization is its own class, so CounterBox<int> and CounterBox<double> keep separate counts. This is a total-constructions counter: it never goes down when an object is destroyed. The tests build three CounterBox<int> and one CounterBox<double>, print both counts, build another double and print its count, build an int inside a block that ends and print the int count once more, and finally print the total of the three int values; one number per line.
Do NOT write a main function.
Expected Output:
3 1 2 4 6
= newline. The output ends with a newline — print one after the last line.
Your Output
Run your code to see the output here...