vector<Flight> flights;
while (!myReadFile.eof()) {
flights.push_back(*(new Flight()));
// read some info...
}
를 벡터에 새 항목을 삽입 할 때 :프로그램이 충돌 두 번째 루프 후 메시지와 함께 프로그램이 충돌
"cpi.exe에서 0x776315de에서 처리되지 않은 예외 :가 0xc0000005 :. 액세스 위반 위치 0xfeeefee2을 읽기"
어떻게 문제를 해결할 수 있습니까?
편집 :
vector<Flight> flights;
while (!myReadFile.eof()) {
flights.push_back(Flight());
// read some info...
}
난이 시도하고 여전히 두 번째 루프에
편집 충돌 : 전체 시도
int count = 0;
myReadFile >> output;
while (!myReadFile.eof()) {
flights.push_back(Flight());
flights[count].setFlightNum(atoi(output));
myReadFile >> output;
int x = atoi(output);
flights[count].setStartX(x);
myReadFile >> output;
int y = atoi(output);
flights[count].setStartY(y);
count++;
myReadFile >> output;
}
당신은 우리에게 생성자 표시 (기본 복사)'Flight'의 수 있습니까? – Naveen
빈 생성자 - 모든 멤버는 int 또는 float입니다. 복사 생성자가 없습니다 – Royi
이것은 라이브 프로젝트입니까? 하늘에있는 우리 친구들을위한 우호적 인 관심사. –