当我试图编译下面的C++程序: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;
}
我得到了以下错误:
上任何想法?
谢谢。
该错误不会出现。 – sergiom 2011-01-27 11:03:30