All pastes #171127 Raw Edit

Anonymous

public text v1 · immutable
·published 2006-09-15 01:48 UTC
rendered paste body

#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