Hello rezy3312,
I put your code in MSVS 2017 and when compiled received 11 errors.
I lost 2 errors when I changed the beginning.
1 2 3 4 5 6
|
#include <iostream>
#include <list>
#include <string> // <--- This is missing. Added.
#include <vector>
using namespace std; // <--- Best not to use.
|
You need to include the <string> header file so that "std::cout" knows how to process a string variable and "std::getline' is defined in the <string> header file and with the header file "std::getline" is undefined.
Next this was flagged:
1 2 3 4
|
string getName()
{
return NAME;
}
|
It looks like you want to return a single name, but "NAME" is defined as a vector, so you are trying to return a vector as a single string. This does not work.
Same is true for "getAmount" and "getBackroom".
In your private variables using all capital letters for the variable names tends to imply that they are defined as constants that can not be changed. Lower case letters for regular variable is more common.
Also Starting a class or a struct with a capital letter is more common.
These are just suggestions you can do what you want, but others might complain.
I do not understand what you are using the try/catch for in "main", but the catch part parameter is a problem. Not something I use often, so I will have to look that one up.
That is just a start that needs fixed before I can see what the program is doing.
One of the first things I noticed is:
1 2 3 4 5 6 7 8 9 10 11
|
void printmenu()
{
cout << "------------- menu list ------------- \n" << endl;
cout << "1: print the stack" << endl;
cout << "2: add item " << endl;
cout << "3: delete item" << endl;
cout << "0: wish to exit" << endl;
cout << "------------------------------------- \n" << endl;
}
|
You do not need a "cout" and "endl" for each line. Also prefer to use the new line (\n) over "endl".
Consider this. It is much easier to work with:
1 2 3 4 5 6 7 8 9 10 11
|
void printmenu()
{
cout <<
" ------------- menu list ------------- \n" // <--- The space at the end does nothing.
// It may take up room on the screen, but you will never know that it is there.
" 1: print the stack\n"
" 2: add item\n"
" 3: delete item\n"
" 0: wish to exit\n"
" ------------------------------------- \n";
}
|
Each line of quoted text may seem separate, but it is actually considered just 1 string.
Andy