Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. class Base
  2. {
  3. public:
  4. virtual void func(int x, float y, unsigned z) = 0;
  5.  
  6. void func(int x)
  7. {
  8. cout << "func with x only" << endl;
  9. }
  10. };
  11.  
  12. class Derived : public Base
  13. {
  14. public:
  15. void func(int x, float y, unsigned z)
  16. {
  17. cout << "func override" << endl;
  18. }
  19.  
  20. };
  21.  
  22. int main()
  23. {
  24. Derived d;
  25. d.func(10); // <<--------- 'COMPILATION ERROR'
  26. return 0;
  27. }
  28.  
  29. error: no matching function for call to 'Derived::func(int&)'
  30. note: candidates are: virtual void Derived::func(int, float, unsigned int)
  31.  
  32. using Base::func;
  33.  
  34. int main()
  35. {
  36. Base && b = Derived();
  37. b.func(10);
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement