Мое задание - создать программу для управления деятельностью ресторана, которая включает в себя функцию репликации пользователя и многие другие функции. Я должен отправить это задание только в 1 файл .cpp поэтому я попытался сжать код только в 1 файл: 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
Может кто-то пожалуйста, скажите мне, что я делаете неправильно здесь и что еще я могу сделать, чтобы улучшить свой код?
Вы не можете вызвать производные классы статической функции таким образом. Дизайн странный BTW. –