I have following problem:
~Set()
{
delete _arraySet;
};
void addToSet(T val)
{
if(_currLen < _maxLen)
{
_arraySet[_currLen] = val;
_currLen++;
}
}
Set<T> operator+(Set& other)
{
Set result;
for(int i=0; i< _currLen; i++)
{
result.addToSet(_arraySet[i]);
}
for(int i=0; i< other._currLen; i++)
{
result.addToSet(other._arraySet[i]);
}
return result;
}
After calling
Set<int> temp = x + x;
in main, I get _BLOCK_TYPE_IS_VALID assert error. To be entirely honest I have no clue as to why it is happening, but after running debug it seems that somehow I delete result from operator+ immediately instead of performing an = operation on it. I'm sorry for not being able to provide any more details...
@Edit:
Looks like I've been missing the Rule of Three. Here's the link to the article for anyone with similar problem. Thanks a lot for help!