This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: pure virtual w/implementation bug in GCC 3.3?


How about this (taken from the standard 10.4 Abstract classes [class.abstract]):

[Note: a function declaration cannot provide both a pure-specifier and a definition ---end note] [Example:

struct C {
          virtual void f() { }=0;                 // ill-formed
};

---end example]

m.

On Thu, 18 Sep 2003 14:52:45 -0500
Eljay Love-Jensen <eljay@adobe.com> wrote:

>Hi Lyle,
>
>>Without actually looking at the standard, isn't a pure virtual function with an implementation simply a contradiction?
>
>No, it's not really the contradiction that it first appears.
>
>The compiler enforces that all derived classes implement the pure virtual function (or become marked as "abstract" themselves).
>
>A pure virtual function can have an imlpementation in that base class, such that derived classes could do a "using basefunc;" to explicitly utilize the base classes behavior implemented in the pure virtual basefunc method.
>
>I grant you, it is a bit unusual.  When I run across one, I tend to do a double take.  But just like have a "const volatile", there are appropriate situations for pure virtuals with implementations.
>
>*grin*
>--Eljay
>
>
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]