fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct A{
  5. void print() const {cout << "A\n";}
  6. };
  7.  
  8. struct B: public A{
  9. void print() const {cout << "B\n";}
  10. };
  11.  
  12. struct C: public B{
  13. void print() const {cout << "C\n";}
  14. };
  15.  
  16. template<class T>
  17. void print(const T &someClass){
  18. someClass.print();
  19. }
  20.  
  21. int main() {
  22. print(A());
  23. print(B());
  24. print(C());
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
A
B
C