   Class instance in member function
  Is it possible to send a class's instance in it's own memberfunction except sending the class instance itself into the constructor every time? I have an example here that requires to do this:    if (py <= y + gfx_coords.h && (py+42) >= y && (px+21)>=x && px<=x + gfx_coords.w) {   if (type=="equipment")  player->AddEquipment(name);   else if (type=="item")  player->AddToInventory(THIS CLASS);    }
  Yes, use the 'this' keyword. It refers to the current class.   ;  I managed to solve it, by adding all the instances into a vector and send in the vector into the show function, like this:// before game loopvector<Item> equipments;    Item equip(255, 255, 0, item_list, gfx);equipments.push_back(equip);// part of the game loopfor (int i=0;i<equipments.size();i++)    equipments.show(&player, equipments, i);But now there is another problem. This is the function that adds the actual item into the inventory but the line: v_item.erase(); makes the game exits every time I touch the item.Code for function:void Item::show(Player *player, vector<Item> &v_item, int element) {    if (py <= y + gfx_coords.h && (py+42) >= y && (px+21)>=x && px<=x + gfx_coords.w) {   if (type!="item")  player->AddEquipment(name, type);   else if (type=="item")  player->AddToInventory(v_item[element], gfx_coords);    v_item.erase(v_item.begin() + element);    }    BlitSurface(x-camera.x, y-camera.y, item, &gfx_coords);}Why does it destroy the program when I pick up the item? I only erase the vector that is outside the function.   