I use operator() as a subscript operator this way:
double CVector::operator() (int i) const
{
if (i >= 0 && i < this->size)
return this->data[i];
else
return 0;
}
double& CVector::operator() (int i)
{
return (this->data[i]);
}
It works when I get values, but I get an error when I try to write assign a value using
a(i) = 1;
UPD: Error text:
Unhandled exception at 0x651cf54a (msvcr100d.dll) in CG.exe: 0xC0000005: Access violation reading location 0xccccccc0.