Re: My final shape program, what do you think?
From: John Harrison (john_andronicus_at_hotmail.com)
Date: 03/17/04
- Next message: bartek: "Re: wicked array assignment [solved]"
- Previous message: David Harmon: "Re: from a file to an array"
- In reply to: John Cho: "Re: My final shape program, what do you think?"
- Next in thread: Mike Wahler: "Re: My final shape program, what do you think?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 16 Mar 2004 23:11:55 -0000
"John Cho" <johncho@johncho.us> wrote in message
news:Xns94AE983F587C2spockieverizonnet@199.45.49.11...
>
> > Shape needs a virtual destructor
> >
> > virtual ~Shape() {}
> >
>
> >> delete shapearray[count];
> >
> > This is undefined behaviour, because of the lack of a virtual
> > destructor. The rule in C++ is that if an object is deleted though a
> > pointer to its base class then the base class must have a virtual
> > destructor or its undefined behaviour.
>
>
> my derive classes do not have destructors orignally, so i should not
> have to use a virtual deconstructor
>
That's not true.
>
>
> i should have to use a virtual deconstructor if i want dervive
> deconstructors to be called before base deconstructors
>
>
> however, none of my classes have deconstructors, hence no need for
> virtual deconstructors
That's not true. The C++ rule is exactly as I said
"The rule in C++ is that if an object is deleted though a
pointer to its base class then the base class must have a virtual
destructor or it is undefined behaviour."
If you don't want to believe me then fine, but the rule is like I said.
john
- Next message: bartek: "Re: wicked array assignment [solved]"
- Previous message: David Harmon: "Re: from a file to an array"
- In reply to: John Cho: "Re: My final shape program, what do you think?"
- Next in thread: Mike Wahler: "Re: My final shape program, what do you think?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|