Practicing menu... help!

Hello, I'm fairly new to C++.
I need help with a bit of code for the beginning of a menu program: I can get it to list the menu, but I am having trouble with the IF statements. Thoughts?

Also, what does

using namespace::std

mean? I cannot get any program to run without it or I get the error "undeclared identifier" for about every line of code I have.

THE CODE

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//Project 2-1A
//Programmer: Argon
//Purpose: Introduce basics of creating a simple menu.
#include <iostream>
#include <string>

//The main function
int main ()

{

//Why is this required?
using namespace::std;

//Initialize the menu choice variable
int Choice;

//The following displays the user's menu choices on the screen
	cout << "1) Add a New Record" << endl;
	cout << "2) Modify an Existing Record" << endl;
	cout << "3) Delete and Existing Record" << endl;
	cout << "4) View/Print and Existing Record" << endl;
	cout << "5) Exit" << endl;

//The following IF statements are supposed to provide output based on the //user's choice.
	if (Choice==1)
		cout << "You chose to add a new record. ";
	if (Choice==2)
		cout << "You chose to modify an existing record. ";
	if (Choice==3)
		cout << "You chose to delete an existing record. ";
	if (Choice==4)
		cout << "You chose to view/print an existing record. ";
	if (Choice==5)
		cout << "You chose to exit. ";

//This command pauses the program and prompts the user to press any key to continue.
system ("pause");

//The return statement ends the function.
return 0;

}
using namespace std;
Is used for accessing methods inside standard (std in short) namespace. cout is 1 method in that namespace. You can instead of
cout << "Hello" << endl;
create same effect using
std::cout << "Hello" << std::endl;
It just makes progams "easier" to create to use using-directive.

On your program:
Where do you use cin (or std::cin) operation to ask from user a input?
cin >> Choice;
or
std::cin >> Choice;

Last edited on
I am an imbecile, sometimes. I put it in just after the menu choices.
Thank you for your quick response!
Topic archived. No new replies allowed.