以下のコードを実行すると、_BLOCK_TYPE_IS_VALID というエラーが発生します。これはベクターに別のオブジェクトを追加することと共通点があると思いますが、どこで間違いを犯したのかわかりません。このプログラムの以前のバージョンはベクトルを使用せずに記述されていて、正常に動作していたため、クラス コードは追加しません。必要に応じて、変数名を英語に翻訳したり、どの変数が何に使用されているかを説明したりできます。
#include "stdafx.h"
#include "CStop.h"
int _tmain(int argc, _TCHAR* argv[])
{
vector<CStop>Stops;
string* array= NULL;
string name,text;
int length,time,howMany,n;
cout<<"How many stops? "<<endl;
cin>>n;
for(int i = 0; i < n; i++)
{
cout<<"Type name, length , time, how many stops"<<endl;
cin>>name>>length>>time>>howMany;
if(howMany> 0)
{
cout<<"Type stops names"<<endl;
array= new string[howMany];
for(int i = 0; i<howMany;i++)
{
cin>>text;
array[i] = text;
}
}
CStops temp(name, length,time,howMany,array);
Stops.push_back(temp);
if(howMany> 0) delete[] array;
}
for(int i=0;i<Stops.size();i++)
{
cout<<Stops[i].Info()<<endl;
}
return 0;
}
よろしくお願いします。