Hello,
I want to use the vector class to work with arrays of classes but I seem to
get in conflict with the delete operator used in the specific class. The
code below gives an assertion?! How is that possible? I have to free the
allocated memory in my class CTest but combination with a vector it seems as
if this is not allowed.
(I'm using VC 6.0)
Can somebody give me a clue what going and how to tackle this problem?
regards
Stijn
#include <vector>
using namespace std;
class CTest
{
public:
CTest();
~CTest();
double* x;
};
CTest::CTest()
{
x=new double[10];
}
CTest::~CTest()
{
if(x!=NULL)
delete [] x;
x=NULL;
}
int main(int argc, char* argv[])
{
vector<CTest> arrTest;
arrTest.resize(1);
return 0;
}