First snippet: Lines 15: You're doing a getline to line.
Line 18: You're pushing tempString. tempString does not appear to have been defined. You want to be pushing line, not tempString.
I was wondering is there a way to then get the user option and do something with it WITHOUT simply hard coding |
Unfortunately, there is no simple way to dynamically associate a text entry in your file with a specific section of code.
One approach is to put everything related to a menu selection in the file (food name, price, etc). Then your code to order a specific food becomes generic.
Another approach you might want to consider is create a std:map<string, funcptr>. You would initially load the map with the various names and function pointers to the code to handle that entry. Then when you read the file, you can check if the name is in the map. If so, you then have a pointer to the function to call when that menu item is selected.
open other text files with that name and giver yet another menu. |
It's certainly possibly to open another file, but you still have the problem of associating an entry with code associated with those entries.