Skip to content

Instantly share code, notes, and snippets.

@maluramichael
Created November 2, 2014 15:23
Show Gist options
  • Save maluramichael/4337a58dddf904e2d282 to your computer and use it in GitHub Desktop.
Save maluramichael/4337a58dddf904e2d282 to your computer and use it in GitHub Desktop.
class Foo {
public:
Foo()
{
// wird weg optimiert oO
std::cout << "construct\n";
}
~Foo()
{
// der hier auch
std::cout << "destruct\n";
}
void bar() { std::cout << "bar\n"; }
};
int main(int argc, char* argv[])
{
std::shared_ptr<Foo> p;
// vorallem wie kann bar ausgegeben werden wenn Foo nicht richtig initialisiert wurde?
p->bar();
std::shared_ptr<Foo> p2 = p;
p2->bar();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment