Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: C++  |  size: 0.32 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <iostream>
  2.  
  3. class A{ public: A() : x(0) {} int x; };
  4. class B{ public: B() : x(1) {} int x; };
  5.  
  6. class C
  7. {
  8. public:
  9.     void foo(A a) { std::cout << a.x << std::endl; }
  10.     void foo(B b) { std::cout << b.x << std::endl; }
  11. };
  12.  
  13. int main()
  14. {  
  15.     A a;
  16.     B b;
  17.     C c;
  18.     c.foo(a);
  19.     c.foo(b);
  20. }