我先重载一个运算符号“[ ]”
node cnodearray::operator[](int i)
{
if((i<maindex)&&(i>=0))
{
return *mpocn[i];//返回第n个指针所指对象
}
else
{
if(mpocn[i]==NULL)
{
cout<<"没有元素,出错"<<endl;
exit(0);
}
cout<<"数组越界"<<endl;
exit(0);
}
}
假定我想代入i=2,请问在main函数当中,我是应该写成xxx[]2,还是xxx[2],还是xxx[](2)?
Helenr
相关分类