[ create a new paste ] login | about

Link: http://codepad.org/WruGLvD9    [ raw code | output | fork ]

C++, pasted on Nov 12:
#include <iostream>

class A {
  public:
    void foo() {
      std::cout << "A" << std::endl;
    }
};

class B {
  public:
    void foo() {
      std::cout << "B" << std::endl;
    }
};

class C {
  public:
    void foo() {
      std::cout << "C" << std::endl;
    }
};

template <class T> void foo(T obj) {
  obj.foo();
}

int main(int argc, char *argv[]) {
  A a;
  B b;
  C c;

  foo(a);
  foo(b);
  foo(c);

  return 0;
}


Output:
1
2
3
A
B
C


Create a new paste based on this one


Comments: