class A{
public:
virtualvoid func();
};
class B : public A{
void func(bool f = true);
};
A* var = new B();
var->func(); // This should call B's func(), but calls the one from A
Why is this happening? The default parameter isn't considered as a separated signature (func())?
The default parameter isn't considered as a separated signature (func())?
Parameters aren't signatures, so your question doesn't make much sense.
But to addresss what I think you're asking, B::func is a function which takes as an argument one value of type bool. A::func is a function which takes no arguments. Providing a default argument for B::func does not in any way change the signature of the function. So, as ne555 says, the signatures do not match.
You say that I'm not overriding...
But if I call just func() (with no args, and let's say I don't have the default argument in B), then my compiler says that there isn't such function and I need to add "using A::func" to make it work... how is this "behaviour" called?