I have the following code:
template <unsigned int size>
struct Vector {
float v[size];
Vector() {}
~Vector() {}
Vector<size> &operator=(const Vector<size> &w);
};
template <unsigned int size>
inline Vector<size> &Vector<size>::operator=(const Vector<size> &w) {
unsigned int i;
for (i = 0; i < size; i++)
v[i] = w.v[i];
return *this;
}
|
and
class OBJModel {
~OBJModel() {
...
delete[] vertices;
}
initOBJModel() {
...
vertices = new Vector<3>[vertexCount];
if (!vertices) { _ERROR_ }
}
private:
...
Vector<3> *vertices;
}
|
When ~OBJModel is (automatically) called, produces an error (a memory error, I suppose) with the following message:
Debug Assertion Failed!
Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
And the call stack is:
_free_dbg(void * 0x007f1db0, int 1) line 1050 + 82 bytes
free(void * 0x007f1db0) line 956 + 11 bytes
operator delete(void * 0x007f1db0) line 7 + 9 bytes
Material::`vector deleting destructor''(unsigned int 3) + 87 bytes
Model::~Model() line 17 + 30 bytes
I suppose that I''m doing something wrong, but I can''t find the error. If with this info someone could tell me something ...