#include <iostream>
int a = 9;
int *p;
p = &a;
int fun();
int main()
{
std::cout << fun();
return 0;
}
int fun()
{
return *p;
}
的價值爲什麼這個代碼給錯誤:分配全局指針
expected constructor, destructor, or type conversion before '=' token|
鑑於此代碼運行正常:
#include <iostream>
int a = 9;
int *p = &a;
int fun();
int main()
{
std::cout << fun();
return 0;
}
int fun()
{
return *p;
}
請注意[格式化您的代碼,如常見問題中所述](http://meta.stackexchange.com/q/22186) – razlebe