Before I write this, I realize there are way better ways to accomplish what I am asking, but I am JUST wondering if it is possible to do it the way I am asking.
I have a main function called system. The system has a menu and depending on input, it
calls subfunctions to do user requisted tasks.
The user will supply a file that contains some data. The first line of the data is the size of the structure in which this data is to be stored (A graph consisting of an array of singly linked lists). I would like one function to read, create and populate this array from the file, then use another function to analyze it.
The problem I am encountering is how can the other function access this structure if it is to be dynamicaly created within the first function? (therefore a temporary object)
This works fine if I combine everything in one function, I am just wondering if it is somehow possible to make this structure reusable once one function has built it (remember, it is not part of the system because the size is not known until the user supplies the file). I am guessing one solution is for the first function to return this structure? Is there an easier way? This solution would require a complicated copy constructor.
PS. I would like to thank Vijay for helping me out with this (school) project so far.