我想這個代碼我的錯在哪裏?
#include <iostream>
#include <vector>
#include <string>
#include <iterator>
using namespace std;
class Tex
{
public:
int ii;
};
vector <Tex> tex;
vector <Tex>::iterator itexx;
int main()
{
Tex texx;
texx.ii = 9;
tex.push_back(texx);
cout << itexx->ii;
return 0;
}
當我運行這段代碼,編譯器是給我段錯誤或者更確切地說,「程序收到SIGSEGV段錯誤」。
我不知道這個錯誤的含義。我的代碼有什麼問題?
你的代碼應該做什麼? – thebjorn
是不是打印出來9; – user241621
好的,但在這些情況下問自己的問題是_how_是否應該發生,然後驗證您假設的每一步...... – thebjorn