Re: [linux-audio-dev] A C++ question

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] A C++ question
From: Niels A. Moseley (n.a.moseley_AT_student.utwente.nl)
Date: Fri Apr 18 2003 - 14:15:45 EEST


Hi,

>Another, is when I am linking, it complains about the vtable and won't
>compile. This error leaves me baffled because usually the class compiled
>and ran before without any problems, and I didn't change it at all.
>
>class thisFooWillNotCompile
>{
>public:
>
> virtual void thisFooMakesMeAngry() = 0;
>};
>
>class thisFooIsNoGood : public thisFooWillNotCompile
>{
>public:
>
> void thisFooMakesMeAngry() { printf("I will not link I will say
>vtable blah blah blah and die..\n"); }
>};
>
>
>Sorry I am vague but, if I knew why this was happening, I would be an
>advanced C++ programmer.One of them appears to be an error in my code,
>but the way it manifests itself is weird.

You always need a virtual destructor in the class if you do inhertance.
Otherwise upon destruction of the derived class, the baseclass destructor
will not be called.

Cheers,
Niels.

so:

class thisFooWillNotCompile
{
public:
        virtual ~thisFooWillNotCompile(); // ADD THIS!
        virtual void thisFooMakesMeAngry() = 0;
};

class thisFooIsNoGood : public thisFooWillNotCompile
{
public:
   virtual ~thisFooIsNoGood(); // ADD THIS!

   void thisFooMakesMeAngry() { printf("I will not link I will say vtable
blah blah blah and die..\n"); }
};


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Fri Apr 18 2003 - 14:22:46 EEST