Anonymous
public text v1 · immutable
#include <iostream>
struct foo
{
int x;
foo(int y) : x(y) {std::cout<<"Constructor: "<<x<<"\n";}
~foo() {std::cout<<"Destructor"<<x<<"\n";}
};
void bar()
{
static foo quux(1);
}
foo baz(2);
int main()
{
foo zod(3);
bar();
return 0;
}
=================================
$ ./a.out
Constructor: 2
Constructor: 3
Constructor: 1
Destructor3
Destructor1
Destructor2