[英]"+1 Overload --- Function definition for '...' not found" Along With "Unable to start program. The system cannot find the file specified"
This code is written for homework where I am prompting user input to calculate hospital bills based on whether the patient was admitted as an inpatient or an outpatient, along with user-inputted rates and charges.这段代码是为作业而写的,我在作业中提示用户输入以根据患者是住院还是门诊以及用户输入的费率和费用来计算医院账单。 The issue I am having is that when I try to run the code, the system first tells me that there are build errors and asks if I would like to continue.我遇到的问题是,当我尝试运行代码时,系统首先告诉我存在构建错误并询问我是否要继续。 After continuing, I get the following error message:继续后,我收到以下错误消息:
"Unable to start program. [File Path] The system cannot find the specified file" “无法启动程序。[文件路径]系统找不到指定的文件”
I was going through my code and the only thing I could see was that the function prototypes before the main function had a message stating that the function definition could not be found.我正在检查我的代码,我唯一能看到的是主要 function 之前的 function 原型有一条消息,指出找不到 function 定义。
Are there issues with my code or is this purely an issue with Visual Studio 2017?我的代码有问题还是这纯粹是 Visual Studio 2017 的问题? My directory doesn't look out of order or anything like that.我的目录看起来没有乱序之类的。
// PGM6 - Overloaded Hospital - 11.15.2020
#include "pch.h"
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
double inpatient(int days, double rateDaily, double chargesService, double chargesMeds, double chargesTotal);
double outpatient(double chargesService, double chargesMeds, double chargesTotal);
int main()
{
int patientType;
cout << "Please enter (1) for Inpatient or (2) for Outpatient" << endl;
cin >> patientType;
if (patientType == 1)
double inpatient();
else
if (patientType == 2)
double outpatient();
else
cout << "Please enter (1) or (2)." << endl;
}
double inpatient()
{
int days;
double rate;
double chargesService;
double chargesMeds;
double chargesTotal = (days * rate) + chargesService + chargesMeds;
cout << "Days: ";
cin >> days;
cout << endl;
cout << "Daily Rate: ";
cin >> rate;
cout << endl;
cout << "Service Charges: ";
cin >> chargesService;
cout << endl;
cout << "Medication Charges: ";
cin >> chargesMeds;
cout << endl << endl;
cout << "Total Charges: " << chargesTotal << endl;
return chargesTotal;
}
double outpatient()
{
double chargesService;
double chargesMeds;
double chargesTotal = chargesService + chargesMeds;
cout << "Service Charges: ";
cin >> chargesService;
cout << endl;
cout << "Medication Charges: ";
cin >> chargesMeds;
cout << endl << endl;
cout << "Total Charges: " << chargesTotal << endl;
return chargesTotal;
}
Here is what you did wrong这是你做错了什么
I think this working code do what you need:我认为这段工作代码可以满足您的需求:
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
double inpatient();
double outpatient();
int main()
{
int patientType;
cout << "Please enter (1) for Inpatient or (2) for Outpatient" << endl;
cin >> patientType;
if(patientType == 1)
inpatient();
else if(patientType == 2)
outpatient();
else
cout << "Please enter (1) or (2)." << endl;
}
double inpatient()
{
int days;
double rate;
double chargesService;
double chargesMeds;
cout << "Days: ";
cin >> days;
cout << endl;
cout << "Daily Rate: ";
cin >> rate;
cout << endl;
cout << "Service Charges: ";
cin >> chargesService;
cout << endl;
cout << "Medication Charges: ";
cin >> chargesMeds;
cout << endl << endl;
double chargesTotal = (days * rate) + chargesService + chargesMeds;
cout << "Total Charges: " << chargesTotal << endl;
return chargesTotal;
}
double outpatient()
{
double chargesService;
double chargesMeds;
cout << "Service Charges: ";
cin >> chargesService;
cout << endl;
cout << "Medication Charges: ";
cin >> chargesMeds;
cout << endl << endl;
double chargesTotal = chargesService + chargesMeds;
cout << "Total Charges: " << chargesTotal << endl;
return chargesTotal;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.