因为如果我定义了operator==,那么比较是可能的:
class My
{
int x;
// ...
public:
My(int);
bool operator==(const My & y);
// ...
};
//...
My one = 1;
switch (one)
{
case 1 : // anything
default : // ...
}但只有整数类型才有可能。为什么?
https://stackoverflow.com/questions/31441541
复制相似问题