The compiler supports exceptions fine... my own user defined exceptions work perfectly.
Code:
template<class ItemType>
const bool BST3<ItemType>::IsFull(){
/*****
Tests if tree is full by catching the bad_alloc() exception
bad_alloc() exception is thrown if no memory is available for data
to be allocated
******/
try{
BST3_node* temp_ptr;
temp_ptr = new BST3_node; //Check for one node allocation
delete temp_ptr;
}
catch( bad_alloc error ){ return true; }
return false;
}
There is an example of an IsFull function for a binary search tree I did for my non-linear data structures class. All compiles and runs fine under vC++ 6.0 -- and compiles fine with gcc/g++ 2.96 if I remove the lines that catch the bad_alloc.
Code tags amended by Hammer