I'm filling std::vector<Box> boxes
with 9 Box
objects, each with their own string variable name
. Just as an error check, I'm trying to go through the vector of objects and print each object's name
variable. However, the console remains blank. Here's the function that fills and prints the vector:
void Engine::FillVector(){
Board board;
for(int i = 0; i < 9; i++){
Box box;
board.GetBoxes().push_back(box);
}
int size = board.GetBoxes().size();
for(int i = 0; i < size; i++){
board.GetBoxes()[i].SetName("box");
std::cout << board.GetBoxes()[i].GetName();
}
}
So "box" should be displayed nine times in the console right? GetBoxes
simply returns the vector boxes
, and SetName
also simply sets each Box
object's name to "box"
. Why does the console remain blank?