Question w.r.t. `'class Foo' has virtual functions but non-virtual destructor` warning.
Mws
mws@twisted-brains.org
Fri Mar 4 14:57:00 GMT 2005
On Friday 04 March 2005 15:51, Karel Gardas wrote:
>
> Hello,
>
> I would like to ask if the behaviour of GCC 4.0.0 20050301 is correct or
> not. I have for example abstract base class like:
>
> class Foo
> {
> public:
> virtual unsigned short
> iiop_version() const = 0;
> };
hi Karel,
imho if you use virtual functions you are going to derive other classes from Foo.
so you should (must) provide a virtual ~Foo();
so if your derived class will be deleted all the desctructors down to base class are found and
executed.
so imho, gcc does the right thing here to complain about the code.
regards
marcel
> and when I compile it, GCC emits warning from subject, although this class
> is really abstract and will never be instantiated. It's quite easy to add
> virtual dtor there, but I'm reluctant to do so, since IMHO GCC should
> check if the class is abstract or not, so I would like to ask if I should
> fill a bugreport or correct my code.
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20050304/937199d4/attachment.sig>
More information about the Gcc
mailing list