
Virtual Function with Different Return Type
Can I give a virtual function in a derived class a different return type
that the one in the base class?
ie:
class base{
virtual base* ptr() { return this; }
Quote:
}
class derived:: public base{
virtual derived* ptr() { return this; }
Quote:
}
Stroustrup seems to say that this is just fine ( The C++ Programming
Language, 3rd Edition Section 15.6.2 pg 424). However, VC++ 6.0 says
"error C2555: 'Cond::new_expr' : overriding virtual function differs from
'Expr::new_expr' only by return type or calling convention."