Skip to content

Instantly share code, notes, and snippets.

@zachelko
Created April 3, 2010 02:20
Show Gist options
  • Save zachelko/354009 to your computer and use it in GitHub Desktop.
Save zachelko/354009 to your computer and use it in GitHub Desktop.
Arbitary scope
class Foo
{
public:
Foo() { std::cout << "ctor\n"; }
~Foo() { std::cout << "dtor\n"; }
};
int main()
{
std::vector<Foo> foos;
{
Foo foo;
foos.push_back(foo);
}
std::cout << "Only 1 Foo object exists at this point, good!\n";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment