hi there, could any of you pros help me out on how to start an menu-based console application using C++ functions? I dont think i'd be able to cope with OOD as im still new to c++. Not too sure on how to call out each function from the menu
Console menu
Collapse
X
-
Are you looking for something that involves Design Patterns? Is this supposed to be a GUI, or a text-based menu?Originally posted by JeremyThi there, could any of you pros help me out on how to start an menu-based console application using C++ functions? I dont think i'd be able to cope with OOD as im still new to c++. Not too sure on how to call out each function from the menu
We need a bit more to help - how are you trying to call the function from the menu now? -
Thanks for the reply, it's supposed to be a text-based menu. It's supposed to be able to launch functions to find ID's, write new ID's and save new ID's as well.Originally posted by sicarieAre you looking for something that involves Design Patterns? Is this supposed to be a GUI, or a text-based menu?
We need a bit more to help - how are you trying to call the function from the menu now?Comment
-
Seems pretty straightforward , what part are you getting stuck on?Originally posted by JeremyTThanks for the reply, it's supposed to be a text-based menu. It's supposed to be able to launch functions to find ID's, write new ID's and save new ID's as well.Comment
-
Try an infinite loop:
Code:while (1) { cin >> choice; case 1: Add(...); break; case 2: Revise(...); break; case 3: Exit(); return 0; }Comment
-
Ok, well then, let's start with the basics: do you know how to print stuff out and read variables in?Originally posted by JeremyTPretty much everything, kinda have no clue on how to code a menu :/
Do you have your functions created? Do you know how to call them? Have you tested them and know that they work?Comment
-
You can have a series of cout statements that explain the options and then have a number correspond to each option like:Originally posted by JeremyTPretty much everything, kinda have no clue on how to code a menu :/
1: first option
2: second option
etc.
then check what number the user entered and perform the correct function.Comment
-
Oops. forgot the switch
Try an infinite loop:
Code:while (1) { cin >> choice; switch(choice) { case 1: Add(...); break; case 2: Revise(...); break; case 3: Exit(); return 0; } }Comment
-
I wouldn't recommend an infinite loop, but that's a personal preference, I don't like break statements. I'd suggest having a sentinel/exit value to check (have one of the cases be 'exit' and set a boolean, so the while will fail).Originally posted by weaknessforcatsTry an infinite loop:
Code:while (1) { cin >> choice; case 1: Add(...); break; case 2: Revise(...); break; case 3: Exit(); return 0; }
But as I said, that's personal preference, weaknessforcats ' method will certainly work.Comment
Comment