我正在尝试通过 eclipse cdt 编写一个基于控制台的计算器。但是识别我的 struct Calc 似乎有问题
有我的头文件:
#ifndef __CALC_H__
#define __CALC_H__
#include <iostream>
struct Calc {
Calc();
Calc(const Calc &other);
bool error;
int display;
char oper;
int result;
int memory;
void digit(int digit);
void op(char oper);
void equals();
void memPlus();
void memClear();
void memRecall();
bool isError() const;
void allClear();
};
std::ostream &operator<<(std::ostream &out, const Calc &c);
#endif
和我的源文件
#include "calc.h"
void doOperation(Calc& calc){
switch(calc.oper){//ide tells me oper cant be resolved
case '+':
break;
case '-':
break;
case '*':
break;
case '/':
break;
}
}
void Calc(){
}
void Calc(const Calc& other){//ide tells me Calc does not name a type
}
所以问题是 1.oper 不能被识别为 Calc 的数据成员 2.当我使用 Calc 作为参数时,eclipse 找不到类型 Calc 我哪里做错了?提前致谢!