fork download
  1. #include <iostream>
  2.  
  3. template <typename Derived, typename T> struct Foo {
  4.  
  5. void CallBar () {
  6. static_cast<Derived*>(this)->Bar();
  7. }
  8. };
  9.  
  10. struct Baz : public Foo<Baz, int> {
  11.  
  12. void Bar () {
  13. std::cout << "Bars everywhere, bitches.\n";
  14. }
  15.  
  16. };
  17.  
  18. int main (int argc, char* argv[]) {
  19.  
  20. Baz baz;
  21. baz.CallBar();
  22.  
  23. }
Success #stdin #stdout 0s 2928KB
stdin
Goo goo gooo!
stdout
Bars everywhere, bitches.