我希望重载一个函数来检查结构体对象是否为空。
这是我的结构体定义:
struct Bit128 {
unsigned __int64 H64;
unsigned __int64 L64;
bool operate(what should be here?)(const Bit128 other) {
return H64 > 0 || L64 > 0;
}
}
这是测试代码:
Bit128 bit128;
bit128.H64 = 0;
bit128.L64 = 0;
if (bit128)
// error
bit128.L64 = 1
if (!bit128)
// error
operator bool()
。作为一个不带参数的成员函数。 - Peter