【发布时间】:2023-03-13 07:49:02
【问题描述】:
我正在尝试从切换菜单访问方法以显示存储在向量中的数据。但是,我不确定如何告诉案例 1 采用方法调用中的方法。 错误列表如下:
Error 1 error C2065: 'applicant' : undeclared identifier
Error 2 error C2275: 'Applicant' : illegal use of this type as an expression
Error 3 error C3861: 'viewApp': identifier not found
下面是我目前正在处理的代码有问题。
do
{
std::cout << "Menu\n";
std::cout << "\t1. View Applications\n";
std::cout << "\t2. Record Orders\n";
std::cout << "Enter your selection: ";
cin >> option;
switch (option)
{
case 1:
{
viewApp(Applicant& applicant);
}
break;
case 2:
{
Order cO;
cO.createOrder();
}
default:
std:cout << option << " is not a valid menu item.\n";
std::cout << endl;
}
}
while(option !=5);
这是当前切换菜单的 sn-p,我需要“案例 1”才能转到下面的 viewApp() 方法。
int viewApp(Applicant& applicant) //can't get the switch to go to this method
{
//code
}
void Order::createOrder() //this works fine and the switch menu goes straight to it
{
//code
}
任何帮助将不胜感激,非常感谢。 汤姆
【问题讨论】:
标签: c++ class pointers methods