I have a question about lists in C++. I am creating a game, where there are a set of insects moving around the screen, and I do this by creating a class, initializing a list, storing the ‘insect’ object and then creating a draw and move function. Now, I want to be able to pass this list as well as a similiar list of ‘insecticide spray’ from another class to the ‘main’ loop, where the game loop is running continuously. Is this possible? If so how? And is it a good idea to do so? Passing whole lists back and forth?
Share
Welcome to stackoverflow Pen!
If it were me, I’d pass it by reference (especially if you have a lot of bugs…pardon the pun). It’s definitely possible! This is just psuedo-ish code…but hopefully it can help
you get going in the right direction!
Kind Regards,
-sf
EDIT: Almost forgot to demonstrate the passing by reference!