0
我只是在學習C++的基礎知識,並且已經涉及到關於指針的部分。但是,在嘗試爲指針的內容賦值時出現錯誤。有小費嗎?EXEC_BAD_ACCESS使用指針時發生xcode
#include <iostream>
class X
{
public:
int * x;
X()
{
int * x = new int;
}
};
int main (int argc, const char * argv[])
{
X test;
*(test.x) = 10;
return 0;
}
該代碼似乎很好,編譯,你會發布錯誤信息嗎? – imreal