私はC++が初めてなので、ご容赦ください。
次のような構造体を作成しました。
struct node{
double startPoint;
double endPoint;
vector<node*> children;
void addChild(node *aNode){
children.push_back(aNode);
}
void addPoints(double start, double end){
startPoint = start;
endPoint = end;
}
};
私のプログラムの行には、次のものがあります。
vector<node*> data;
....
node *temp = (node*)malloc(sizeof(node));
temp->addPoints(lexical_cast<double>(numbers[0]), lexical_cast<double>(numbers[1]));
data[index]->addChild(temp);
ここで、"Index" はベクター データのインデックスです。これらのlexical_cast
数値を文字列から double に変換しています。
行まですべてが機能しaddChild(temp)
ます。
端末はこれを吐き出します:
First-chance exception at 0x585b31ea (msvcr90d.dll) in Tree.exe: 0xC0000005: Access violation reading location 0xcdcdcdc1.
Unhandled exception at 0x585b31ea (msvcr90d.dll) in Tree.exe: 0xC0000005: Access violation reading location 0xcdcdcdc1.
しかし、私はそれに対処する方法がわかりません。