Re: shouldn't need graf3d

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Fri Mar 03 2000 - 15:55:26 MET


Hi Ivana,

   an interface without pure abstract (=0) methods can still be abstract.
Pure abstract methods require an implementation in a derived class, where
the compiler will check that the required methods are provided. But there
is nothing wrong with an abstract interface without pure abstract methods.
You loose the extra check of the compiler, but it is easier to implement
just a subset of methods in a derived class without the compiler nagging you
to override all methods. In that case very clear documentation is necessary
telling you what is expected to make a concrete implementation.

Another extreme is a class with 100 methods and only one pure abstract (=0)
method. I would not call such an interface a real abstract interface. There
the single pure abstract method is just a reminder to provide the one required
"user" method.


Cheers, Fons.



Ivana Hrivnacova wrote:
> 
>  Hi Valery,
> 
>  Just one comment for not confusing C++ beginners
>  by using incorrect terminology:
> 
> On Thu, 2 Mar 2000, Valeri Fine (Faine) wrote:
> 
> > TPadView3D is an abstract interface between TPad and some concrete
> > 3D viewer. So it must  be linked with very TPad but should impose no extra
> > dependencies since all its methods look as follows:
> >
> > inline void TPadView3D::ExecuteEvent(Int_t, Int_t, Int_t) { }
> > inline void TPadView3D::Paint(Option_t *) { }
> > inline void TPadView3D::Size(Int_t, Int_t) { }
> > inline void TPadView3D::PaintBeginModel(Option_t *) { }
> > inline void TPadView3D::PaintEnd(Option_t *) { }
> > inline void TPadView3D::PaintScene(Option_t *) { }
> > inline void TPadView3D::PaintPolyMarker(TPolyMarker3D *, Option_t *) { }
> > inline void TPadView3D::PaintPolyLine(TPolyLine3D *, Option_t *) { }
> > inline void TPadView3D::PaintPoints3D(const TPoints3DABC *,Option_t *){ }
> > inline void TPadView3D::SetAttNode(TNode *, Option_t *) { }
> > inline void TPadView3D::SetLineAttr(Color_t ,Int_t ,Option_t *) { }
> > inline void TPadView3D::UpdateNodeMatrix(TNode *, Option_t *) { }
> > inline void TPadView3D::UpdatePosition(Double_t ,Double_t ,Double_t ,TRotMatrix *, Option_t *){ }
> 
>   This is not an abstract interface as it does not contain any
>   abstract method. The abstract methods look like this:
> 
> > inline void TPadView3D::ExecuteEvent(Int_t, Int_t, Int_t) = 0;
> > inline void TPadView3D::Paint(Option_t *) = 0;
>   ... etc.
> 
>   Making a method abstract enforces all derived classes to
>   provide implementation of this method. If you omit this
>   implementation than you will not be able to instantiate
>   such derived class.
>   (Compiler will give you error on "new MyDerivedClass" if
>    implementation of any abstract method is missing.)
> 
>   This is used in interfaces for ensuring that all interface
>   implementation will provide the required methods.
> 
>   Best regards,
> 
>   Ivana Hrivnacova
> 
> ==============================================================
> e-mail:  Ivana.Hrivnacova@cern.ch
> address: PPE Division; 160-1-016; CERN; 1211 Geneve; Switzerland
> phone:   (022)-767-9749
> Home institute: NPI Rez near Prague, Czech Republic
> ==============================================================

-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7677910



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:20 MET