I would like to inherit a member function without redefining it, but giving it different default values. What should I do?
class Base{
public:
void foo(int val){value=val;};
protected:
int value;
};
class Derived : public Base{
public:
void foo(int val=10);
};
class Derived2 : public Base{
public:
void foo(int val=20);
};
void main(){
Derived a;
a.foo();//set the value field of a to 10
Derived2 b;
b.foo();//set the value field of b to 20
}