struct A {
virtual int foo(const int bar);
};
int A::foo(const int bar)
{
return 0;
}
struct B : public A {
int foo(int bar);
};
int B::foo(int bar)
{
return 1;
}
int
main()
{
A *p = new B;
const int baz=-1;
int r = p->foo(baz);
return 0;
}
here B::foo is called (tried with g++3.2.3)
i wonder if it's a problem for non elementary types in parameters
since derived function can modify the baz argument with impunity
contrary to the expectations of the caller.
Granted, B::foo could've taken bar as the const parameter
and casted to non const but there are no casts of any
kind in the program above.