fork download
  1. #include <iostream>
  2.  
  3. void foo()
  4. {
  5. std::cout << "global foo()" << std::endl;
  6. }
  7.  
  8. struct A {
  9. void foo()
  10. {
  11. std::cout << "A::foo()" << std::endl;
  12. }
  13. };
  14.  
  15. struct C {
  16.  
  17. };
  18.  
  19. template <typename T>
  20. struct B : public T {
  21. void call()
  22. {
  23. T::foo();
  24. }
  25. };
  26.  
  27. int main(int argc, char **argv )
  28. {
  29. B<A> a;
  30. a.call();
  31.  
  32. B<C> c;
  33. c.call();
  34. return 0;
  35. }
  36.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In member function ‘void B<T>::call() [with T = C]’:
prog.cpp:33:   instantiated from here
prog.cpp:23: error: ‘foo’ is not a member of ‘C’
stdout
Standard output is empty