当我尝试编译以下C++程序时:
//Source: C++ How To Program, Sixth Edition
#include <iostream>
int main()
{
int a;
int *aPtr;
a=7;
aPtr=&a;
std::cout<<"The address of a is: "<<&a<<std::endl;
std::cout<<"The value of aPtr is: "<<aPtr<<std::endl;
std::cout<<"The value of a is: "<<a<<std::endl;
std::cout<<"The value of *aPtr is: "<<*aPtr<<std::endl;
std::cout<<"Showing that * and & are inverses of each"
<<" other"<<std::endl;
std::cout<<"&*aPtr= "<<&*aPtr<<std::endl;
std::cout<<"*&aPtr= "<<*&aPtr<std::endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
有什么想法吗?
谢谢.
更换
std::cout<<"*&aPtr= "<<*&aPtr<std::endl;
Run Code Online (Sandbox Code Playgroud)
通过
std::cout<<"*&aPtr= "<<*&aPtr<<std::endl;
Run Code Online (Sandbox Code Playgroud)
只是代码中的语法错误(<
而不是<<
).