pure virtual functions and name injection

John Love-Jensen eljay@adobe.com
Tue Mar 7 16:17:00 GMT 2006


Hi Jérôme,

> Ok, i guess this is because of the same name...

Yes, that is correct.

>...but why is it ok with the C++ standard?
> operator++(int) and operator++() do have the same name, but they are
> considered
> as different by a c++ compiler...

I'm not sure.  I suspect it's a C legacy allowance.  A kluge.  A wart in the
C++ standard.

> Technically, a::foo() is not "defined" anywhere (i understand what
> you mean),
> but it does not need to, since it is a pure virtual functions.
> But a::foo() is "implemented" in class "d" (return 1), so when
> calling a::foo() the
> compiler should redirect the call to the implementation d::foo(), no?

No.

a::foo() is not d::foo().

foo() goes through the virtual function table.  a::foo() is explicitly
a::foo().

HTH,
--Eljay



More information about the Gcc-help mailing list