Skip to content

Instantly share code, notes, and snippets.

@rwcarlsen
Created August 19, 2014 16:55
Show Gist options
  • Save rwcarlsen/199daf5ab59e98adc321 to your computer and use it in GitHub Desktop.
Save rwcarlsen/199daf5ab59e98adc321 to your computer and use it in GitHub Desktop.
class Foo {
public:
Foo() : myfoo(NULL) {};
void eat_cheese(std::string type) {
//...
}
static Foo* TheFoo(int index) {
if (myfoo == NULL) {
myfoo = new Foo();
}
return myfoo;
};
private:
static Foo* myfoo;
int age;
double height;
};
void make_elliott_happy(int foo, int bar, double baz) {
Foo* foo = TheFoo();
foo->age = foo;
// ...
}
void eat_cheese(Foo* foo, std::string name) {
foo->eat_cheese(name);
}
int main(labla) {
// ...
unsigned long int foo = Foo::TheFoo();
make_elliott_happy(foo, blablabla, bar);
eat_cheese(foo, blablabla);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment