#include <iostream>
using namespace std;
class A
{
public:
int fun1(){};
int fun2(){};
};
int main(int argc, char **argv)
{
cout<<"abc.fun1 " << &A::fun1 <<&A::fun2<<endl;
return 1;
}
上面的代码为什么最后的输出是11?
...全文
16014打赏收藏
为什么输出是1, 而不是实际的地址
#include using namespace std; class A { public: int fun1(){}; int fun2(){}; }; int main(int argc, char **argv) { cout<<"abc.fun1 " << &A::fun1 <<&A::fun2<<endl; return 1; } 上面的代码为什么最后的输出是11?
根据03标准$4.12/1
An rvalue of arithmetic, enumeration, pointer, or pointer to member type can be converted to an rvalue of type bool. A zero value, null pointer value, or null member pointer value is converted to false; any other value is converted to true.