So my code has a struct called Storage that first appears in the function void List::set(int no);
For test sake I have it displaying the results inside that same function, where it works fine. The problem comes in when i try to bring with me the same Storage inside another function (after using it to set integers and strings) the output comes out whacky.
Both are bolded . the first one to appear works fine(but i do not want it inside this function) but the second one (which is inside a display function, is exactly where i want it but it does not work...
You declare Storage inside the List::set() scope, so that means once the function ends, the variable will go out of scope.
You can't reference it outside of the function.
There are lots of ways of getting around this -- declaring the variable outside of the function, making storage a pointer to the object array instead, or passing a pointer to the function (which is related to the first choice).