Connecting Tech Pros Worldwide Forums | Help | Site Map

abstract destructor

Tony Johansson
Guest
 
Posts: n/a
#1: Jul 23 '05
Hello!!


Is it possible to have abstract destructor.

//Tony



Rolf Magnus
Guest
 
Posts: n/a
#2: Jul 23 '05

re: abstract destructor


Tony Johansson wrote:
[color=blue]
> Hello!!
>
>
> Is it possible to have abstract destructor.[/color]

Yes.

Tony Johansson
Guest
 
Posts: n/a
#3: Jul 23 '05

re: abstract destructor


[color=blue][color=green]
>> Is it possible to have abstract destructor.[/color]
>
> Yes.[/color]


When should an abstract destructor be used.

//Tony


Kristo
Guest
 
Posts: n/a
#4: Jul 23 '05

re: abstract destructor


Tony Johansson wrote:[color=blue]
> When should an abstract destructor be used.[/color]

Please read the FAQ. It's in there.

Kristo

Victor Bazarov
Guest
 
Posts: n/a
#5: Jul 23 '05

re: abstract destructor


Tony Johansson wrote:[color=blue][color=green][color=darkred]
>>>Is it possible to have abstract destructor.[/color]
>>
>>Yes.[/color]
>
>
>
> When should an abstract destructor be used.[/color]

Let me point out that there is no term "abstract destructor". You can
have a virtual destructor declared pure (just like any other virtual
function), which would make your /class/ abstract. The destructor is
still just 'pure' in that case.

Assuming the conversation is about a pure virtual destructor, the answer
is: when you have no other virtual member functions you want to declare
pure, and you still want your class to be abstract.

V
Jerry Coffin
Guest
 
Posts: n/a
#6: Jul 23 '05

re: abstract destructor


In article <My1le.25534$d5.174858@newsb.telia.net>,
johansson.andersson@telia.com says...[color=blue]
> Hello!!
>
>
> Is it possible to have abstract destructor.[/color]

Hopefully you really mean virtual destructor. In that case, the
answer is yes. A virtual destructor is necessary if you might ever
delete an instance of a derived class via a pointer or reference to
the base class.

Alternatively, you might mean a pure virtual destructor, which would
make this an abstract base class. In that case the answer is still
yes. The same condition as above applies here as well, but in this
case (is with any other pure virtual function) the function must be
overridden in some derived class for objects to be instantiated. IOW,
just like any other Abstract Base Class, this one can't be
instantiated itself -- it just defines an interface that will be
supported by derived classes.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Closed Thread