Skip to content

Instantly share code, notes, and snippets.

@dylon
Last active December 15, 2015 08:29
Show Gist options
  • Save dylon/5230988 to your computer and use it in GitHub Desktop.
Save dylon/5230988 to your computer and use it in GitHub Desktop.
Stupid C++ Tricks
#include <stdio.h>
struct Foo {
const int baz;
Foo(const int baz) : baz(baz) {}
};
struct Qux : public Foo {
Qux(const int baz) : Foo(baz) {}
};
class Bar : public Qux {
public:
Bar(const int baz) : Qux(baz) {}
};
struct Quo : public Bar {
Quo(const int baz) : Bar(baz) {}
};
int main(int argc, char *argv[]) {
Quo quo(42);
printf("The answer to life is: %d\n", quo.baz);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment