Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: Coding question



> Christian Gmeiner wrote:
> 
> Hi Mailingliste,
> 
> i have here a question about coding.
> 
> Klaus uses abstract (virtual) classes, but why is he also using the virtual keyword in this way:
> 
> class cDvbDevice : public cDevice {
> private:
>   static bool Probe(const char *FileName);
>          ///< Probes for existing DVB devices.
> public:
>   static bool Initialize(void);
>          ///< Initializes the DVB devices.
>          ///< Must be called before accessing any DVB functions.
>          ///< \return True if any devices are available.
> private:
>   fe_type_t frontendType;
>   int fd_osd, fd_audio, fd_video, fd_dvr, fd_stc;
> protected:
>   virtual void MakePrimaryDevice(bool On);
> public:
>   cDvbDevice(int n);
>   virtual ~cDvbDevice();
>   virtual int ProvidesCa(const cChannel *Channel) const;
>   virtual bool HasDecoder(void) const;
> 
> // SPU facilities
> 
> private:
>   cDvbSpuDecoder *spuDecoder;
> public:
>   virtual cSpuDecoder *GetSpuDecoder(void);
> 
> // Channel facilities
> 
> private:
>   cDvbTuner *dvbTuner;
>   void TurnOffLiveMode(void);
> public:
>   virtual bool ProvidesSource(int Source) const;
>   virtual bool ProvidesTransponder(const cChannel *Channel) const;
>   virtual bool ProvidesChannel(const cChannel *Channel, int Priority = -1, bool *NeedsDetachReceivers = NULL) const;
> protected:
>   virtual bool SetChannelDevice(const cChannel *Channel, bool LiveView);
> public:
>   virtual bool HasLock(void);
> 
> 
> I always thought that i only need to use virtual on the motherclass and the childclass dont need it.
> In my biggest project, a game engine, i dont use virtual in the childclass.
> Could somebody explain this to me?
> 
> Thanks, Christian

I do it this way because I want to see immediately when looking at
a child class which functions are virtual.

IMHO it was a mistake of Bjarne Stroustrup to allow the 'virtual'
keyword to be left out in child classes.

Klaus




Home | Main Index | Thread Index