[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

overloadklasser og nedarvede funktioner.



Hej.

Jeg har ngole klasser defineret som foelger

--------------------------------------------
class CSource {
  public:
        CSource(CConfig* pConfig);
  virtual ~CSource();
  virtual bool Init();
};
class CAudioSource : public CSource {
public:
	CAudioSource(CConfig* pConfig);
	~CAudioSource();
	bool Init();
};
class CSinusAudioSource : public CAudioSource {
  public:
        CSinusAudioSource(CConfig* pConfig, char* srcID);
        ~CSinusAudioSource();
	bool Init();
};
----------------------------------------------

Desuden har jeg

----------------------------------------------
CAudioSource::CAudioSource(CConfig* pConfig) : CSource(pConfig) {
}
CAudioSource::Init() {
}
CSinusAudioSource::CSinusAudioSource(CConfig* pConfig) : CAudioSource(pConfig) {
CSinusAudioSource::Init() {
}
----------------------------------------------


(Eksemplet kan ikke compileres, der der er problemer med Init() i baade CAudioSource() og CSinusAudioSource(), men lad os lige ligge det for en stund.

Naar jeg kalder konstruktoren for CSinusAudioSource() kaldes foerst konstruktoren for CAudioSource() der foerst kalder konstruktoren for CSource(). meget fint og godt.

Men naar jeg kalder CSinusAudioSource::Init() ville jeg gerne foerst have kaldt CAudioSource::Init(). Hvordan goer man det ?

Ideen er jeg har noget kodet som

  CAudioSource *as = NULL;
  ....
  as = new CSinusAudioSource();
  as->Init();

Her skulle Init gerne kalde Init for CSinusAudioSource som gerne foerst skulle kalde Init for CAudioSource.

Hvordan goer man ?

mvh.

Peter

 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2007-09-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *