#include
using namespace std;
#include
struct ho
{
int math;
char jiu;
};
struct hao
{
CList list;
int operator
{
int u = 0;
POSITION pos = list.GetHeadPosition();
while (pos)
{
ho dat=list.GetAt(pos);
if (h == u)
{
return dat.jiu;
}
list.GetNext(pos);
}
}
void add()
{
ho di;
cin >> di.jiu >> di.math;
}
};
int main()
{
hao h;
h.add();
cout << h[0] << endl;
}
调试时说:
h[0] 没有与这些操作数匹配的“[]”运算符怎么回事求大神解救一下
你是想做什么?你也没有重载这个操作符指定运算,也没有创建h为数组,指针,怎么可以这样使用[]?
看下我的博客,里面有重载[]运算符的。
应该是需要运算符重载的
h对象属于数组对象,或者用重载运算