This is a potential memory leak, correct? arr
won't be deallocated if the constructor throws, right? I have read that the destructor won't be called in this case, but any sub objects of badType would be, however I think the array won't here because it's a raw pointer, correct?
class badType
{
private:
int* arr;
int myLen, myNum;
public:
badType(int myLen, int aNum)
{
this->myLen = myLen;
arr = new int[myLen];
if (aNum < 100)
throw exception{ "Da number is too low" };
myNum = aNum;
}
~badType()
{
delete[] arr;
}
};