Could you tell me what is wrong with my class constructor? Code:
CVector::CVector (int size_)
{
if (size_ > 0)
{
this->size = size_;
this->data = new double[size];
for (int i = 0; i < size; i++)
{
(*this)(i) = i;
}
}
cout << "constructor end" << endl;
return;
}
Usage example:
tvector = CVector(6);
I get an access violation after "constructor end" output.
Update: Constructor call was incorrect. Using
CVector tvector(6); worked.