Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
C++ version of code from Eric Lippert's blog post "Construction destruction" http://ericlippert.com/2013/06/10/construction-destruction/
#include "stdafx.h"
class SideEffects
{
public:
static void Alpha() { printf("Alpha\n"); }
static void Bravo() { printf("Bravo\n");}
static void Charlie() { printf("Charlie\n"); }
static inline void M();
};
class Foo
{
private:
int x;
int y;
public:
Foo(int x, int y)
{
this->x = x;
this->y = y;
SideEffects::Alpha(); // Notice: does not use "this"
}
~Foo()
{
SideEffects::Charlie();
}
};
void SideEffects::M()
{
Foo foo = Foo(1, 2);
Bravo();
}
int _tmain(int argc, _TCHAR* argv[])
{
SideEffects::M();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.