编译器未识别从类函数的呼叫作为课堂成员
compiler is not recognizing call to function from class as member of class
试图弄清为什么我会遇到错误:函数中未解决的外部主参考
标题文件:
#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',这是该过程的入口点
相关文章:
- 将成员变量添加到共享库中的类中,不会破坏二进制兼容性吗
- 对RValue对象调用的LValue ref限定成员函数
- 为什么使用 "this" 指针调用派生成员函数?
- 具有奇怪重复模板模式的派生类中的成员变量已损坏
- 助记符和指向成员语法的指针
- 用于访问容器<T>数据成员的正确 API
- 内置函数可查看CPP中的成员变量
- 是否可以初始化不可复制类型的成员变量(或基类)
- 如果C++类在类方法中具有动态分配,但没有构造函数/析构函数或任何非静态成员,那么它仍然是POD类型吗
- 找不到成员对象:没有名为get_event()的成员,也处理多态性和向量
- 嵌套在类中时无法设置成员数据
- 为什么在没有显式默认构造函数的情况下,将另一个结构封装在联合中作为成员的结构不能编译
- 将函数类成员映射到类本身内部
- 基于另一个成员参数将函数调用从类传递给它的一个成员
- 将Ref对象作为类成员
- 将包含C样式数组的对象初始化为成员变量(C++)
- 课堂中成员函数模板的明确实例
- 编译器未识别从类函数的呼叫作为课堂成员
- 使用虚拟成员从课堂制作 POD
- 错误:课堂没有名为“ Show”的成员