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
}
~CBarcodeCode12 8 ()
{
// destroy stuff 4
}
}
in my main application i do this:
CBarcode *barcodeClient;
bool someKindOfBoole an = true;
if (someKindOfBool ean)
{
barcodeClient= new CBarcodeCode128 ();
}
else
{
// CBarcodeInterle aved2of5 is like CBarcode128 a child class of
CBarcode
barcodeClient= new CBarcodeInterle aved2of5();
}
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
}
~CBarcodeCode12 8 ()
{
// destroy stuff 4
}
}
in my main application i do this:
CBarcode *barcodeClient;
bool someKindOfBoole an = true;
if (someKindOfBool ean)
{
barcodeClient= new CBarcodeCode128 ();
}
else
{
// CBarcodeInterle aved2of5 is like CBarcode128 a child class of
CBarcode
barcodeClient= new CBarcodeInterle aved2of5();
}
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
Comment