我正在编写一个类,其中包含一个成员函数“insert”,将字符串数组复制到类内容中,该内容是一个向量数组。
但是,这个终止错误一直弹出,说我超过了Vector的末尾,但我不明白为什么....
这是代码:
/////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////// Map class /////////////////////
class Map
{
private:
/////////////////////////////////////////// Map Variables ///////////////
string _name;
vector <string> _contents;
public:
Map(string name){_name = name;
_contents.reserve(56);};
~Map(){};
string getName()
{
return _name;
};
vector <string> getContents()
{
return _contents;
};
/////////////////////////////////////////// Insert ////////////////////////
// string* to an array of 56 strings;
bool Insert(string* _lines_)
{
for (int I = 0; I < 3; I++)
{
_contents[I] = _lines_[I];
}
return true;
};
};
如果您需要更多信息,请随时询问!谢谢!