I have a list of pointers as a member of a class. I instantiate that class, and various functions such as size() and empty() fail with a segfault when the list is empty. W
int Player::addToInv(Thing& t) { if (inventory.size() <= 52) { inventory.push_back(&t); } else { shiplog("Cannot add to inventory, 52 item limit reached",10); return 0; }
}
Thing is passed by reference, but then its address is passed to inventory.push_back(). Try just passing 't'.