當我試圖編譯下面的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