class Base
{
public:
void foo() { cout << "Base::foo" << endl; }
};
class Derived : public Base
{
public:
using Base::foo; // 자식에서도부모의foo를호출하겠다. 1의에러를보완!!
void foo(int a) { cout << "Derived::foo" << endl; }
};
void main()
{
Derived d;
//d.foo(); // 1. error 부모와자식간엔오버로딩을성립하지않는다.
d.foo();
d.foo(10); // 2. ok..
}
Tag | C++