Afficher un message
Vieux 30/12/2007, 05h49   #1
SeniorLee
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Deleting array of derived class

i had a question while i was reading the book "MEC++ chapter 3"

in the book, he says this will not work.

class BST
{
public:
virtual ~BST() { cout << "BST" << endl; }
};

class BalancedBST : public BST
{
public:
~BalancedBST() { cout << "BalancedBST" << endl; }
};

void delete(BST array[])
{
delete [] array;
}

BalancedBST *balTreeArray = new BalancedBST[10];

deleteArray(balTreeArray);


but with the VIsual C++ 2005 it seems to be worked fine

the set of "BalancedBST" and "BST" is printed 10 times.

did i understand the book wrong way? or it's just because of compiler
dependency?
  Réponse avec citation
 
Page generated in 0,05556 seconds with 9 queries