#include <iostream>
#include <map>
#include <string>
using namespace std;
class X
{
public:
int operator[](int key)
{
switch(key)
{
case 1:
return 10;
break;
case 2:
return 20;
break;
default:
return 0;
break;
}
}
};
int main()
{
X a;
cout<<a[1]<<" "<<a[2]<<endl;
system("pause");
return 0;
}c++ operator[]的例子
最新推荐文章于 2023-11-01 17:33:07 发布

4675

被折叠的 条评论
为什么被折叠?



