codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <iostream.h> class Base { public: virtual ~Base() {} virtual void doSomething() const; virtual void doSomething(int x) const; }; void Base::doSomething() const { std::cout << "ping\n"; } void Base::doSomething(int x) const { std::cout << "pong\n"; } class Derived : public Base { public: void doSomething() const; using Base::doSomething; // void doSomething(int x) const { Base::doSomething(x); } }; void Derived::doSomething() const { std::cout << "hello\n"; } int main(int argc, char **argv) { Base base; base.doSomething(); // ping base.doSomething(3); // pong Derived derived; derived.doSomething(); // hello //derived.doSomething(3); // error: no matching function for call to 'Derived::doSomething(int)' //derived.Base::doSomething(3); // pong derived.doSomething(3); return 0; }
Private
[
?
]
Run code
Submit