[ create a new paste ] login | about

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

C++, pasted on Dec 9:
struct IHoge {
virtual ~IHoge(void) {}
virtual void func(void) { std::cout << "hello" << std::endl; }
};

struct IFuga {
virtual ~IFuga(void) {}
virtual void func(void) { std::cout << "world" << std::endl; }
};

struct Foo : IHoge , IFuga {};

int main(void) {
  Foo * p = new Foo;
  IHoge * h = p;
  IFuga * f = p;
  p->func();
  h->func();
  f->func();
  delete p;
  return 0;
}


Output:
1
2
3
In function 'int main()':
Line 17: error: request for member 'func' is ambiguous
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: