S
SeniorLee
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?
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?