【发布时间】:2014-01-18 01:58:06
【问题描述】:
我收到一个错误,它发生在 Chest_vect.push_back(newChest); 行据我所知,我认为它没有任何问题。但我确信我可能错过了一些小事。如果您能提供帮助,将不胜感激!不管怎样,谢谢!
class Chest_objects {
private:
int loc_x, loc_y;
int map_x, map_y;
string obj_name = "";
string obj_id = "";
bool obj_trigger = false;
bool obj_visible = false;
public:
void setLoc_x(int x)
{
loc_x = x;
}
void setLoc_y(int y)
{
loc_y = y;
}
//OTHER GETTER AND SETTER FUNCTIONS NOT INCLUDED
Chest_objects(int x, int y); //CONSTRUCTOR FUNCTIONS: NOTE I DON'T HAVE A COMPLETE ONE
Chest_objects();
Chest_objects(int x, int y, int my, int mx, string name, string id, bool trig, bool vis);
int getChestVect(vector<Chest_objects>& Chest_vect, const char*getFile)
{
int amount = 0;
int get_x = 0;
int get_y = 0;
int max_x;
int max_y;
char get_info;
ifstream file;
file.open(getFile);
file >> max_x >> max_y;
while(get_info != '0')
{
file >> get_info;
if(get_info == '.')
{
get_x++;
}
if(get_info == 'B')
{
Chest_objects newChest(get_x, get_y);
Chest_vect.push_back(newChest);
get_x++;
amount++;
}
if(get_x >= max_x)
{
get_x = 0;
get_y++;
}
}
return amount;
}
};
int main()
{
... blah
return 0;
}
Chest_objects::Chest_objects(int x, int y)
{
loc_x = x;
loc_y = y;
}
Chest_objects::Chest_objects()
{
loc_x = 0;
loc_y = 0;
}
错误:在 'void std::vector<_tp _alloc>::_M_insert_aux(std::vector<_tp _alloc>::iterator, const _Tp&) [with _Tp = Chest_objects; _Alloc = std::allocator; std::vector<_tp _alloc>::iterator = __gnu_cxx::__normal_iterator >;类型名 std::_Vector_base<_tp _alloc>::pointer = Chest_objects*]':|
错误:'std::ios_base::ios_base(const std::ios_base&)' 是私有的|
【问题讨论】: