U
unknown;
hi,
i've got a problem with destroying an inherited object.
i've got the following:
class CBarcode
{
CBarcode ()
{
// do stuff 1
}
~CBarcode ()
{
// destroy stuff 2
}
}
class CBarcodeCode128 : public CBarcode
{
CBarcodeCode128 () : CBarcode()
{
// do stuff 3
}
~CBarcodeCode128 ()
{
// destroy stuff 4
}
}
in my main application i do this:
CBarcode *barcodeClient;
bool someKindOfBoolean = true;
if (someKindOfBoolean)
{
barcodeClient= new CBarcodeCode128();
}
else
{
// CBarcodeInterleaved2of5 is like CBarcode128 a child class of
CBarcode
barcodeClient= new CBarcodeInterleaved2of5();
}
this seems to work
but when i want to destroy object 'barcodeClient' ( delete
barcodeClient; ) it seems that only the destructor of CBarocode will
execute but not the destructor of CBarcodeCode128.
How do i deal with this.
Many thanks
i've got a problem with destroying an inherited object.
i've got the following:
class CBarcode
{
CBarcode ()
{
// do stuff 1
}
~CBarcode ()
{
// destroy stuff 2
}
}
class CBarcodeCode128 : public CBarcode
{
CBarcodeCode128 () : CBarcode()
{
// do stuff 3
}
~CBarcodeCode128 ()
{
// destroy stuff 4
}
}
in my main application i do this:
CBarcode *barcodeClient;
bool someKindOfBoolean = true;
if (someKindOfBoolean)
{
barcodeClient= new CBarcodeCode128();
}
else
{
// CBarcodeInterleaved2of5 is like CBarcode128 a child class of
CBarcode
barcodeClient= new CBarcodeInterleaved2of5();
}
this seems to work
but when i want to destroy object 'barcodeClient' ( delete
barcodeClient; ) it seems that only the destructor of CBarocode will
execute but not the destructor of CBarcodeCode128.
How do i deal with this.
Many thanks