Advertisement
Guest User

Untitled

a guest
Jul 1st, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.23 KB | None | 0 0
  1. struct A {
  2.     A &f() {
  3.         return *this;
  4.     }
  5. };
  6.  
  7.  
  8. struct B : A {
  9.     void foo() {};
  10. };
  11.  
  12.  
  13. int main() {
  14.     B b;
  15.     b.f().foo();
  16. }
  17.  
  18.  
  19. // obvious compiler error: class 'A' has no member method named 'foo'.
  20. // how do I make this work?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement