------- Comment #1 from herwig at gdsys dot de  2008-03-31 06:41 -------
Hi yuri,

I think, this is perfectly correct code and GCC is right in accepting it. First
of all, see "Effective C++" issue 14 about the pure virtual destructor. Then
see here:

http://en.wikipedia.org/wiki/Virtual_function#Abstract_classes_and_pure_virtual_functions

<cite>
Although pure virtual methods typically have no implementation in the class
that declares them, pure virtual methods in C++ are permitted to contain an
implementation in their declaring class, providing fallback or default
behaviour that a derived class can delegate to if appropriate.
</cite>

Regards,
Björn Herwig

(In reply to comment #0)
> GCC compiles the code below without any error:
> 
> //----------------------------------
> class A {
> protected:
>   virtual void foo() const = 0;
> };
> 
> // Defining pure virtual functions should not be allowed.
> void A::foo() const 
> {
> }
> //----------------------------------
> 


-- 

herwig at gdsys dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |herwig at gdsys dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35772

Reply via email to