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
10 5618
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
Are 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?
Are 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?
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.
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.
Seems pretty straightforward, what part are you getting stuck on?
Pretty much everything, kinda have no clue on how to code a menu :/
Try an infinite loop: -
while (1)
-
{
-
cin >> choice;
-
case 1:
-
Add(...);
-
break;
-
case 2:
-
Revise(...);
-
break;
-
case 3:
-
Exit();
-
return 0;
-
}
-
Pretty much everything, kinda have no clue on how to code a menu :/
Ok, well then, let's start with the basics: do you know how to print stuff out and read variables in?
Do you have your functions created? Do you know how to call them? Have you tested them and know that they work?
Pretty much everything, kinda have no clue on how to code a menu :/
You can have a series of cout statements that explain the options and then have a number correspond to each option like:
1: first option
2: second option
etc.
then check what number the user entered and perform the correct function.
Oops. forgot the switch
Try an infinite loop: -
while (1)
-
{
-
cin >> choice;
-
switch(choice)
-
{
-
case 1:
-
Add(...);
-
break;
-
case 2:
-
Revise(...);
-
break;
-
case 3:
-
Exit();
-
return 0;
-
}
-
}
-
Try an infinite loop: -
while (1)
-
{
-
cin >> choice;
-
case 1:
-
Add(...);
-
break;
-
case 2:
-
Revise(...);
-
break;
-
case 3:
-
Exit();
-
return 0;
-
}
-
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).
But as I said, that's personal preference, weaknessforcats' method will certainly work.
Yea most of the functions work, and finally got it done recently. Thanks guys!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Paul Johnston |
last post by:
I'm using VB.Net. I've tried using Console.Read() but it requires a
line-terminator before it finishes (doesn't that mean it's functionally
equivalent to ReadLine() -- why have it then?). I've...
|
by: Roberto Dias |
last post by:
Could anyone give me some tips about how to start a menu-based console
application using C++ function oriented programming techniques? I'm a
FORTRAN-based electrical engineer and a newbie on C++...
|
by: ajikoe |
last post by:
Hello All,
It is said that :
Enabling the console window is easy. From Microsoft Visual Studio®, right-click on the project and choose Properties. Change the output type from Windows Application...
|
by: Ron |
last post by:
Hello,
how do you pass args to a console app?
class TestApp
{
static void Main(string args)
{
//
// TODO: Add code to start application here
|
by: MumboJumbo |
last post by:
Hi I have a really basic question hopefully some can help me with:
Can you write a (i.e. one) C# project that works from the cmd line and gui?
I seems if i write a GUI app it can't write to...
|
by: Michael C |
last post by:
Is it possible to have an app that is both a console app and a windows app?
If there are no command line switches then it will run as a console app, if
there are command line switches then it will...
|
by: Dilip |
last post by:
Hi All
I have a server based C# console application. This application must
hide its console window when its launched out on the field. So I
dutifully P/Invoke'd FindWindow/ShowWindow...
|
by: Stephen Thomas |
last post by:
Hi there
I wonder if any one has encountered this problem or can suggest what is
wrong. I am trying the a procedure from the msn site but get the following
message:
Error 1 The type or...
|
by: Dilip |
last post by:
I have written a C# based console application. Due to some issues
thats been causing me endless nightmares, I was wondering, is there a
way to prevent right mousebutton clicks on my application...
|
by: =?Utf-8?B?UGFvbG8=?= |
last post by:
I'm learning C# via console apps (to avoid getting bogged down in Windows
stuff). I'm wondering how the OO paradigm would work.
Say I'm developing 'classic' menu-driven apps where a menu gives a...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |