[ create a new paste ] login | about

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

epper - C++, pasted on Jan 3:
#include <iostream>
using namespace std;

class type1 {}; class type2{};

class A {
public:
  virtual string foo(type1 a){return "A::foo(type1)";}
  virtual string foo(type2 a){return "A::foo(type2)";}
};

class B : public A {
public:
  virtual string foo(type1 a){return "B::foo(type1)";}
};

int main () {
  B* b = new B();
  
  cout << b->foo(type1()) << endl; // WORKS
  cout << b->foo(type2()) << endl; // compile error: no matching function for B::foo(type2
}


Output:
1
2
3
In function 'int main()':
Line 21: error: no matching function for call to 'B::foo(type2)'
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: