#include
using namespace std;
#include
struct ho
{
int math;
char jiu;
};
struct hao
{
CList<ho> list;
char operator[](int h)
{
POSITION pos=list.GetHeadPosition();
int u = 0;
while (pos)
{
ho dar = list.GetAt(pos);
if (u == h)
{
return dar.math;
}
}
}
void add(ho l)
{
list.AddHead(l);
}
};
int main()
{
ho hm;
hm.jiu = 'l';
hm.math = 'd';
hao h;
h.add(hm);
h[0];
cout << h[0] << endl;
return 0;
}
调试时可以输出h[0]是d
但是它会显示没有与这些操作数匹配的“[]”运算符
求详细代码