Last active
December 15, 2015 08:29
-
-
Save dylon/5230988 to your computer and use it in GitHub Desktop.
Stupid C++ Tricks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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