[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]![]() |
![]() |
![]() |
|||||||||||||||||||||||||
|
|||||||||||||||||||||||||||
![]() |
![]() |
![]() |
Peter Maersk-Moller wrote: > 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. Der mangler retur typen for: CAudioSource::Init() CSinusAudioSource::Init() Der burde stå: bool CAudioSource::Init() { } bool CSinusAudioSource::Init() { } > 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 ? Læs svar fra Martin Møller Skarbiniks Pedersen (John =;-)
![]() |
![]() |
![]() |
||||||||||||
|
||||||||||||||
![]() | ||||||||||||||
|
||||||||||||||
![]() |
![]() |
![]() |