次のように、operator()を添え字演算子として使用します。
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]);
}
値を取得すると機能しますが、を使用して値を割り当てて書き込もうとするとエラーが発生します
a(i) = 1;
UPD:エラーテキスト:
CG.exeの0x651cf54a(msvcr100d.dll)で未処理の例外:0xC0000005:アクセス違反の読み取り場所0xccccccc0。