编译器未识别从类函数的呼叫作为课堂成员

compiler is not recognizing call to function from class as member of class

本文关键字:课堂 成员 呼叫 识别 类函数 编译器      更新时间:2023-10-16

试图弄清为什么我会遇到错误:函数中未解决的外部主参考

标题文件:

#define SURGERY_H
#include <string>
using namespace std;
class Surgery {
private:
static int didhave[5];
static float costs[5], total;
static string types[5];
public:
friend void requestInput();
friend float sendTotal();
};
static float costs[5] = { 100.00, 200.00, 300.00, 400.00, 500.00 };
static string types[5] = { "Tonsil", "Foot", "Knee", "Shoulder", "Appendix"            }   ;
static int didhave[5] = { 0, 0, 0, 0, 0 };

#endif

手术的CPP文件。h类标头文件,其中包含功能定义:我觉得我已经完全丢失了,因为我一直在为此工作了大量小时

#include <iostream>
#include "Surgery.h"
#include <string>
using namespace std;

void requestInput() {
string input;
while(input[0]!='1'){
cout << "Which types of surgery did the patient have? 1) for finished.n";
cin >> input;
if(input[0]=='T' || input[0]=='t')
didhave[0]=1;
else if(input[0]=='F' || input[0]=='f')
didhave[1]=1;
else if(input[0]=='K' || input[0]=='k')
didhave[2]=1;
else if(input[0]=='S' || input[0]=='s')
didhave[3]=1;
else if(input[0]=='A' || input[0]=='a')
didhave[4]=1;
else
cout << "Invalid Surgery Type.";
}
}
float sendTotal() {
int i;
float total;
for(i=0; i<5; i++){
if(didhave[i]==1)
total+=costs[i];
}
return total;
}

主:

#include <iostream>
#include "Surgery.h"
int main(void){
Surgery surgeries;
surgeries::requestInput();
system("pause");
return 0;
}

您需要在某个地方定义函数'main',这是该过程的入口点