我可以知道如何解决代码中的错误吗?
May i know how to solve the errors i have in my code?
问题:我可以知道如何解决代码中的错误,查看全部并在不使用任何链表的情况下删除客户想要和不想要的华夫饼吗?
C:\Users\Arianna\Documents\LABC++\Lab2\ASSIGNMENT DSA SEM2 2.cpp 在函数 'void orderForm()' 中: 321 17 C:\Users\Arianna\Documents\LABC++\Lab2\ASSIGNMENT DSA SEM2 2.cpp [错误] "extraFillings"未在此范围内声明 332 41 C:\Users\Arianna\Documents\LABC++\Lab2\ASSIGNMENT DSA SEM2 2.cpp [错误] 类型为二进制"运算符/"的无效操作数"const char [29]"和"无效 335 19 C:\Users\Arianna\Documents\LABC++\Lab2\ASSIGNMENT DSA SEM2 2.cpp [错误] "extraToppings"未在此范围内声明 341 15 C:\Users\Arianna\Documents\LABC++\Lab2\ASSIGNMENT DSA SEM2 2.cpp [错误] "taxInvoice"未在此范围内声明 355 1 C:\Users\Arianna\Documents\LABC++\Lab2\ASSIGNMENT DSA SEM2 2.cpp [错误] 此处不允许在"{"标记之前使用函数定义 569 11 C:\Users\Arianna\Documents\LABC++\Lab2\ASSIGNMENT DSA SEM2 2.cpp [错误] 输入末尾的预期"}">
#include<iostream>
#include<string>
using namespace std;
int main()
{
char choice,options;
char *tmp,*tmp2;
int sentinel=0;
double priceSoft1=10.00,priceCrispy1=12.00,priceSoft2=14.00,priceCrispy2=16.00,priceSoft3=12.00,priceCrispy3=14.00;
double payment,total;
double TotalAmt1,TotalAmt2,TotalAmt3,TotalAmt4,TotalAmt5,TotalAmt6;
double Fillings=1.20,Toppings=1.50;
double TotalAmount1,TotalAmount2,TotalAmount3,TotalAmount4,TotalAmount5,TotalAmount6;
char wMenu[100];
int listOption,orderForm;
int num1,num2,num3,num4,num5,num6;
}
class waffle
{
private:
struct cashier
{
char name [30]; //Name up to 30 letters
int idNum; //Id Number in Integer
cashier *next;//Pointer to the next node
};
cashier *start_ptr;//Start pointer (root)
public:
waffleShop()
{
start_ptr=NULL;
}//Add constructor and initialize start pointer to NULL
int cashierList();
void add_new_acc();
void displayList();
void delete_start_ptr();
void delete_end_node();
};
int waffle::cashierList()
{
char choice,options;
int listOption=0;
cout<<"Please choose the option from the list";
cout<<"<<1>>Add node at the end of the list"<<endl;
cout<<"<<2>>Display List"<<endl;
cout<<"<<3>>Delete first"<<endl;
cout<<"<<4>>Delete last"<<endl;
cout<<"<<5>>Sign Out"<<endl;
cin>>listOption;
switch(listOption)
{
case 1:
add_new_acc();
break;
case 2:
displayList();
break;
case 3:
delete_start_ptr();
break;
case 4:
delete_end_node();
break;
case 5:
cout<<"Would you like to sign out?";
cout<<" n Press [Y] for Yes, and [N] for No.nntEnter Choice : ";
cin >>choice;
if ((choice !='N')&&(choice !='n'))
{
return cashierList();
}
else
{
cout<<"You have already sign out from the system";
system("cls");
}
break;
}
return 0;
}
void waffle::add_new_acc()
{
cashier *tmp,*tmp2;//temporary pointers
tmp=new cashier;
//Reserve space for the new node to fill in data
cout<<"Create New Account"<<endl;
cout<<"Please enter your name:"<<endl;
cin>>tmp->name;
cout<<"To create your Cashier ID"<<endl;
cout<<"Please enter last 4 digit of your Id: "<<endl;
cin>>tmp->idNum;
tmp->next=NULL;
if(start_ptr==NULL)
start_ptr=tmp;
else
{
tmp2=start_ptr;//The list is not empty since it is not NULL
while(tmp2->next!=NULL)
tmp2=tmp2->next;//move to next link
tmp2->next=tmp;
}
cashierList();
}
void waffle::displayList()
{
char wMenu[100];
cashier *tmp;
tmp=start_ptr;
while(tmp)
{
cout<<"Cashier Name:"<<tmp->name<<endl;
cout<<"Cashier Id:"<<tmp->idNum<<endl;
tmp=tmp->next;
}
main();
}
void waffle::delete_start_ptr()
{
cashier *tmp;
tmp=start_ptr;
start_ptr=start_ptr->next;
delete tmp;
cashierList();
}
void waffle::delete_end_node()
{
cashier *tmp1,*tmp2;
if(start_ptr==NULL)
cout<<"You're not in the list"<<endl;
else
{
tmp1=start_ptr;
if(tmp1->next==NULL)
{
cout<<"You are a New User!!"<<endl;
delete tmp1;
start_ptr=NULL;
}
else
{
while(tmp1->next !=NULL)
{
tmp2=tmp1;
tmp1=tmp1->next;
}
delete tmp1;
tmp2->next=NULL;
}
}
cashierList();
}
void wMenu()
{
char options;
cout<<"----------------------------------------------------------------------";
cout<<"WAFFLE TYPE ! CRISPY(RM) ! SOFT(RM) ! EXTRA CHARGE(RM) !";
cout<<"----------------------------------------------------------------------";
cout<<"1)American ! 12.00 ! 10.00 ! - RM1.20 for additional filling";
cout<<"2)Belgium ! 16.00 ! 14.00 ! - RM1.50 additional topping";
cout<<"3)Rolled ! 14.00 ! 12.00 !/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t";
cout<<"----------------------------------------------------------------------";
cout<<"Options:";
cout<<"nFilling-choc,butter,kaya,ice cream,strawberry,blueberry";
cout<<"nTopping(except for Rolled Waffle)";
cout<<"a)ice cream-vanila,chocolate or mix flavour";
cout<<"b)fruits-banana or strawberry";
cout<<"----------------------------------------------------------------------";
cout<<"Would you like proceed your order?"<<endl;
cin>>options;
cout<<" n Press [Y] for Yes, and [N] for No.nntEnter Options : ";
if ((options !='N')&&(options !='n'))
{
main();
}
else
{
cout<<"Next Customer please ";
return wMenu();
}
}
void orderForm()
{
int order, choiceA,choiceB;
int num1,num2,num3,num4,num5,num6;
double AmountSale1,AmountSale2,AmountSale3,AmountSale4,AmountSale5,AmountSale6;
double priceSoft1=10.00,priceCrispy1=12.00,priceSoft2=14.00,priceCrispy2=16.00,priceSoft3=12.00,priceCrispy3=14.00;
cout<<"----------------------------------";
cout<<"(1)Soft American Waffle RM10.00 ";
cout<<"----------------------------------";
cout<<"(2)Crispy American Waffle RM12.00 ";
cout<<"----------------------------------";
cout<<"(3)Soft Belgium Waffle RM14.00 ";
cout<<"----------------------------------";
cout<<"(4)Crispy Belgium Waffle RM16.00 ";
cout<<"----------------------------------";
cout<<"(5)Soft Rolled Waffle RM12.00 ";
cout<<"----------------------------------";
cout<<"(6)Crispy Rolled Waffle RM14.00 ";
cout<<"----------------------------------";
while(order!=0)
{
do
{
cout<<"nFrom the waffle menu , what would you like : ";
cin>>order;
}
while(1<order<5);
switch(order)
{
case 1:
cout<<"How many soft American waffle would you like:";
cin>>num1;
AmountSale1=priceSoft1*num1;
break;
case 2:
cout<<"How many crispy American waffle would you like:";
cin>>num2;
AmountSale2=priceCrispy1*num2;
break;
case 3:
cout<<"How many soft Belgium waffle would you like: ";
cin>>num3;
AmountSale3=priceSoft2*num3;
break;
case 4:
cout<<"How many crispy Belgium waffle would you like: ";
cin>>num4;
AmountSale4=priceCrispy2*num4;
break;
case 5:
cout<<"How many soft Rolled waffle would you like :";
cin>>num5;
AmountSale5=priceSoft3*num5;
break;
case 6:
cout<<"How many crispy Rolled waffle would you like :";
cin>>num6;
AmountSale6=priceCrispy3*num6;
break;
default:cout<<"Please choose a valid order from the menun";
}
cout<<" Do you want to add fillings? ";
cout<<" n Press [Y] for Yes, and [N] for No.nntEnter Choice : ";
cin >> choiceA;
if ((choiceA ='Y')&&(choiceA !='N')&&(choiceA ='y')&&(choiceA !='n'))
{
extraFillings();
}
else
{
cout<<"Would you like to add Topings?";
cout<<" n Press [Y] for Yes, and [N] for No.nntEnter Choice : ";
cin>>choiceB;
if((choiceB ='Y')&&(choiceB !='N')&&(choiceB ='y')&&(choiceB !='n'))
{
cout<<"Topping(except ROLLED WAFFLE"/endl;
if(order!=5&&order!=6)
{
extraToppings();
}
else
{
taxInvoice();
}
}
}
}
void extraFillings()
{
int typeofFillings,
cout<<"----------------------------------";
cout<<"(1)Soft American Waffle RM10.00 ";
cout<<"----------------------------------";
cout<<"(2)Crispy American Waffle RM12.00 ";
cout<<"----------------------------------";
cout<<"(3)Soft Belgium Waffle RM14.00 ";
cout<<"----------------------------------";
cout<<"(4)Crispy Belgium Waffle RM16.00 ";
cout<<"----------------------------------";
cout<<"(5)Soft Rolled Waffle RM12.00 ";
cout<<"----------------------------------";
cout<<"(6)Crispy Rolled Waffle RM14.00 ";
cout<<"----------------------------------";
cout<<"Waffle Added with Filings RM1.20 will be charged"
cout<<"Remark: ";
cin>>typeofFillings;
switch(order)
{
case 1:
TotalAmt1=AmountSale1+Fillings;
break;
case 2:
TotalAmt2=AmountSale2+Fillings;
break;
case 3:
TotalAmt3=AmountSale3+Fillings;
break;
case 4:
TotalAmt4=AmountSale4+Fillings;
break;
case 5:
TotalAmt5=AmountSale5+Fillings;
break;
case 6:
TotalAmt6=AmountSale6+Fillings;
break;
default:cout<<"Please choose a valid order from the menun";
}
extraTopings(void);
}
void extraTopings()
{
cout<<"----------------------------------";
cout<<"(1)Soft American Waffle RM10.00 ";
cout<<"----------------------------------";
cout<<"(2)Crispy American Waffle RM12.00 ";
cout<<"----------------------------------";
cout<<"(3)Soft Belgium Waffle RM14.00 ";
cout<<"----------------------------------";
cout<<"(4)Crispy Belgium Waffle RM16.00 ";
cout<<"----------------------------------";
cout<<"*****TOPPINGS OF ROLLED WAFFLE IS INVALID*****";
cout<<"Remark: ";
cin>>typeofTopings;
switch(order)
{
case 1:
TotalAmount1=AmountSale1+Toppings;
break;
case 2:
TotalAmount2=AmountSale2+Toppings;
break;
case 3:
TotalAmount3=AmountSale3+Toppings;
break;
case 4:
TotalAmount4=AmountSale4+Toppings;
break;
default:cout<<"Please choose a valid order from the menun";
}
taxInvoice();
}
void taxInvoice();
{
int ans,select;
double payment;
cout<<"----------------------------------";
cout<<"(1) Normal Waffle ";
cout<<"----------------------------------";
cout<<"(2) Waffle with Fillings ";
cout<<"----------------------------------";
cout<<"(3) Waffle with Toppings ";
cout<<"----------------------------------";
cout<<" You have ordered:nn";
cout<<"Select the selection ";
cin>>select;
if(select==1)
{
cout<<"NORMAL"/endl;
cout<<" ITEMttttQUANTITYtUNIT PRICEtAMOUNT OF SALEn";
cout<<" Soft American Waffle:ttt"<<num1<<"ttRM "<<priceSoft1<<"tRM "<<AmountofSale1<<"n";
cout<<" Crispy American Waffle:tt"<<num2<<"ttRM "<<priceCrispy1<<"tRM "<<AmountofSale2<<"n";
cout<<" Soft Belgium Waffle:t" <<num3<<"ttRM "<<priceSoft2<<"tRM "<<AmountofSale3<<"n";
cout<<" Crispy Belgium Waffle:tt" <<num4<<"ttRM "<<priceCrispy2<<"tRM "<<AmountofSale4<<"n";
cout<<" Soft Rolled Waffle:ttt" <<num5<<"ttRM "<<priceSoft3<<"tRM "<<AmountofSale5<<"n";
cout<<" Crispy Rolled Waffle:ttt"<<num6<<"ttRM "<<priceCrispy3<<"tRM "<<AmountofSale6<<"n";
total=0;
total=total+AmountofSale1+AmountofSale2+AmountofSale3+AmountofSale4+AmountofSale5+AmountofSale6;
}
else
{
if(select==2)
{
cout<<"With Fillings"/endl;
cout<<" ITEMttttQUANTITYtUNIT PRICEtAMOUNT OF SALEn";
cout<<" Soft American Waffle:ttt"<<num1<<"ttRM "<<priceSoft1<<"tRM "<<TotalAmt1<<"n";
cout<<" Crispy American Waffle:tt"<<num2<<"ttRM "<<priceCrispy1<<"tRM "<<TotalAmt2<<"n";
cout<<" Soft Belgium Waffle:t" <<num3<<"ttRM "<<priceSoft2<<"tRM "<<TotalAmt3<<"n";
cout<<" Crispy Belgium Waffle:tt" <<num4<<"ttRM "<<priceCrispy2<<"tRM "<<TotalAmt4<<"n";
cout<<" Soft Rolled Waffle:ttt" <<num5<<"ttRM "<<priceSoft3<<"tRM "<<TotalAmt5<<"n";
cout<<" Crispy Rolled Waffle:ttt"<<num6<<"ttRM "<<priceCrispy3<<"tRM "<<TotalAmt6<<"n";
total=0;
total=total+TotalAmt1+TotalAmt2+TotalAmt3+TotalAmt4+TotalAmt5+TotalAmt6;
}
else
{
if(select==3)
{
cout<<"With Toppings"/endl;
cout<<" Soft American Waffle:ttt"<<num1<<"ttRM "<<priceSoft1<<"tRM "<<TotalAmount1<<"n";
cout<<" Crispy American Waffle:tt"<<num2<<"ttRM "<<priceCrispy1<<"tRM "<<TotalAmount2<<"n";
cout<<" Soft Belgium Waffle:t "<<num3<<"ttRM "<<priceSoft2<<"tRM "<<TotalAmount3<<"n";
cout<<" Crispy Belgium Waffle:tt "<<num4<<"ttRM "<<priceCrispy2<<"tRM "<<TotalAmount4<<"n";
cout<<" Soft Rolled Waffle:ttt "<<num5<<"ttRM "<<priceSoft3<<"tRM "<<TotalAmount5<<"n";
cout<<" Crispy Rolled Waffle:ttt"<<num6<<"ttRM "<<priceCrispy3<<"tRM "<<TotalAmount6<<"n";
total=0;
total=total+TotalAmount1+TotalAmount2+TotalAmount3+TotalAmount4+TotalAmount5+TotalAmount6;
}
}
}
cout<<"ttttttThat would be: RM "<<total<<"n";
cout<<"Order Again[0]no[1]yes"
cin<<ans;
if(ans==0)
{
if(payment<total)
{
cout<<"Insufficient Money";
}
else
{
cout<<"ntEnter Received Cash : ";
cin >> payment;
if(payment>total)
{
change=payment-total;
cout<<"tYour change is:"<<change<<"nnnntt"
}
}
do
{
cout<<" New transaction [0] no [1] yes : ";
cin >> ans;
} while ((ans != 0)&&(ans != 1));
}
system("clsnnntt");
system("PAUSE");
return 0;
}
错误"函数 X 未在此范围内声明"是因为您调用的函数是在文件中调用它的函数之后声明的。在编译时,编译器无法知道它是什么。 例如:orderForm调用extraFillings,它还没有定义,因为它在文件后面定义。 您需要创建一个包含函数原型的头文件并将其链接到您的项目,或者您需要确保在调用方之前声明您正在调用的函数。
- 将鼠标悬停在问题上时与预期">"相关的代码错误
- VI工作室代码错误无法打开输出文件主.exe
- 引入参数化构造函数后显示 LNK 2019 未解析外部符号的代码错误
- 有关矩阵的代码错误导致分段错误(内核转储)
- C++ Schannel POST 400 错误代码错误请求
- Java 本机访问代码错误:"Invalid memory access"
- 代码错误修改
- C++代码错误分配
- "_FCbuild"不能用作函数 - C/C++ 代码错误
- 我的代码错误类型警告 1 警告 C4018 和更多错误
- 代码错误(从 1 到 100 找到质数)
- OpenCV VisualStudio,C 代码错误尝试访问像素
- 当我使用的教程完全没有错误时,为什么我的代码错误
- 简单的NOOB C 输入/输出问题:代码错误
- 为什么enumProcessModules返回false值和299代码错误
- WinhttpSetoption()失败设置TLSV1.2,带有错误代码错误_internet_incorrect_ha
- 苹果安全传输代码错误
- C++ - 国际象棋主教移动代码错误
- 导入Python库时,嵌入了Python代码错误
- 编译提升C 代码错误