Anonymous
public cpp v1 · immutable#include <string>#include <iostream>using namespace std;class Thing { static int count;public: Thing(Thing const & t) { /* No count incr on copy constructor */ } Thing(int i = 0) { ++count; } void print() { cout << count << endl; }};int Thing::count = 0;void foo(Thing t = 2) { t.print();}int main() { Thing a(6); foo(); // 2 foo(); // 3 foo(a); // 3 foo(3); // 4 foo(a); // 4 foo(); // 5 return 0;}