Skip to content

Instantly share code, notes, and snippets.

@hadronized
Created July 23, 2011 12:10
Show Gist options
  • Save hadronized/1101358 to your computer and use it in GitHub Desktop.
Save hadronized/1101358 to your computer and use it in GitHub Desktop.
#include <iostream> // std::cout / std::endl;
using namespace std;
template <class Policy>
struct foo : Policy {
int _a;
foo(void) :
Policy(this) {
cout << "In foo ctor ..." << endl;
}
~foo(void) {
}
void say_hello(void) const {
cout << "Hello, world!" << endl;
}
};
struct print_ctor_policy {
print_ctor_policy(foo<print_ctor_policy> *p) {
p->_a = 4;
cout << p->_a << endl;
p->say_hello();
}
};
typedef foo<print_ctor_policy> foobar2_t;
int main() {
cout << "test" << endl;
foobar2_t omg;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment