我的任務是創建一個程序來管理餐廳的活動,其中包括用戶reconizing功能和許多其他features.I我需要的只有1個.cpp文件提交這項任務所以我試圖將代碼壓縮成只有一個文件:D。以下是我已經在創建用戶界面迄今所做的:錯誤:不是類或命名空間名稱
#include <iostream>
using namespace std;
class UserInterface{
public:
typedef UserInterface super;
static int user_input;
static void menu(){
int input;
print();
setInput(input);
execute();
}
static void print(){
cout << "Welcome to the Restaurant Managing program!" << endl;
cout << "Please enter your ID. The ID of chef is 0 and the ID of customers is a positive integer: ";
};
static bool setInput(int input){
cin >> input;
if (input >= 0){
user_input = input;
return true;
}
else{
cout << "Invalid input!" << endl;
return false;
}
};
static void execute(){
switch (user_input){
case 0:
break;
default:
Customer::menu();
break;
}
};
};
class Customer :public UserInterface{
public:
static void print(){
cout << "1.Exit" << endl << "2.Make an order" << endl << "3.View orders" << endl << "4.Change order" << endl;
cout << "Please enter your ID: ";
}
static bool setInput(int input){
cin >> input;
if (input >= 1 && input <= 4){
user_input = input;
return true;
}
else{
cout << "Invalid input!" << endl;
return false;
}
};
static void exit(){
super::menu();
};
static void makeOrder(){};
static void viewOrder(){};
static void changeOrder(){};
static void execute(){
switch (user_input){
case 1:
exit();
break;
}
};
};
int UserInterface::user_input;
int main(){
int input;
UserInterface::menu();
system("pause");
}
的問題是,當我編譯此代碼我得到這個錯誤:
Error 1 error C2653: 'Customer' : is not a class or namespace name
是否有人可以告訴我,我什麼在這裏做錯了什麼,我還能做些什麼來改進我的代碼?
不能調用派生類的靜態函數的方式。設計是怪異的順便說一句。 –