Victor Bazarov
11/14/2008 8:47:00 PM
..rhavin grobert wrote:
> On 14 Nov., 19:11, Victor Bazarov <v.Abaza...@comAcast.net> wrote:
>> .rhavin grobert wrote:
>>> guess you have ....
>>> class Grandbase {
>>> public:
>>> virtual int foo();
>>> };
>>> class Base: public Grandbase {
>>> /* no foo() specified here */
>>> };
>>> class Derived, public Base {
>>> public:
>>> virtual int foo();
>>> };
>>> my compiler gives no errors, ..but ... is it safe?
>> Define "safe".
>>
>
> does a...
>
> void callfoo(Grandbase* b)
> {
> b->foo();
> };
>
> Derived d;
> callfoo(d);
>
> always call Derived::foo() ?
It won't compile. You probably meant
Derived d;
callfoo(&d);
(and BTW no semicolon after the body of 'callfoo' either), in which
case, yes, it does. And why do you ask here, why don't you just try it?
And what book are you reading that doesn't explain the concept of the
"final overrider", AFA virtual functions are concerned?
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask