为啥这个函数的输出是这样
为什么这个函数的输出是这样?#include iostreamint main(int argc, char* argv[]){const char* strHel
为什么这个函数的输出是这样?
#include <iostream>
int main(int argc, char* argv[]){
const char* str="Hello, world!\n";
std::cout.operator<<(str);
std::cout<<str;
return 0;
}
使用g++命令编译,结果为:
0x403064Hello, world!
[解决办法]cout.operator<<(...)实际上调用的是cout(即ostream)重载的成员方法。