C++에서 복잡한 구조를 구축 할 수없는 : 나는 두 번째 구조에서 인스턴스를 만들려고 다음에 시도 할 때마다나는 다음과 같이 두 가지 기본 구조를 가지고
struct stuSectionProperties
{
int Field1; // Row | BoxNo | SplitterNo
int Field2; // Col | Adapter | -
double Latitude;
bool IsEast;
int Band;
int CableNo;
SDP::Global::enuSections::Type Section;
stuSectionProperties()
{
this->Field1 = -1;
this->Field2 = -1;
this->Latitude = -1;
this->Band = -1;
this->Section = SDP::Global::enuSections::None;
this->CableNo = -1;
}
const char* toStr()
{
return ((QString) (QString::number(this->Field1) + " , " + QString::number(this->Field2) + " , " + QString::number(Latitude) + " , " + QString::number(IsEast) + " , " + QString::number(Band) + " , "
+ QString::number((int) Section) + QString::number((int) CableNo))).toStdString().c_str();
}
};
및
struct stuSearchResult
{
stuSectionProperties MyData;
QList<stuSectionProperties> Connections;
stuSearchResult()
{
this->MyData.Field1 = -1;
this->MyData.Field2 = -1;
this->MyData.Latitude = -1;
this->MyData.Band = -1;
this->MyData.Section = SDP::Global::enuSections::None;
this->MyData.CableNo = -1;
stuSectionProperties stuDummy;
stuDummy.Band=-1;
stuDummy.CableNo=-1;
stuDummy.Field1=-1;
stuDummy.Field2=-1;
stuDummy.IsEast=-1;
stuDummy.Latitude=-1;
stuDummy.Section= SDP::Global::enuSections::None;
this->Connections.append(stuDummy);
}
const char * toStr()
{
return ((QString) (QString::number(this->MyData.Field1) + " , " + QString::number(this->MyData.Field2) + " , " + QString::number(this->MyData.Latitude) + " , " + QString::number(this->MyData.IsEast) + " , " + QString::number(this->MyData.Band) + " , "
+ QString::number((int) this->MyData.Section) + QString::number((int) this->MyData.CableNo)) + " , " + QString::number(this->Connections[0].Field1) + " , " + QString::number(this->Connections[0].Field2)).toStdString().c_str();
}
};
을 toStr() 멤버를 호출하십시오. 저는이 라인에 몇 가지 문제가 있다고 말하는 erro를 얻을 것입니다 :
+ QString::number(this->Connections[0].Field1) + " , " + QString::number(this->Connections[0].Field2)
내 문제는 정확히 무엇인지 말해 주시겠습니까? 안부.
정확한 오류 메시지를 게시하십시오. –
정확한 오류를 게시하십시오. 컴파일러 또는 런타임 오류입니까? –
QList에서 ASSERT 실패 :: 연산자 [] : "인덱스가 범위를 벗어남"파일 /usr/include/QtCore/qlist.h, 403 행 주요 문제는 내가 시도하고있는 목록의 두 요소와 관련이 있습니다 그들을 액세스 할 수 있습니다. –