0
我想写的日食基于控制台的计算器cdt.But那里似乎是承认我的结构Calc的问题结构不是在Eclipse CDT的认可
有我的头文件:
#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不能被识别为计算器 2,当数据的成员,我用计算器如对米,日食找不到类型Calc 我在哪里做错了? 在此先感谢!
虽然这可能会变得更加复杂,我不知道,你真正需要的构造的这个例子。您可能对本教程感兴趣http://www.cplusplus.com/doc/tutorial/structures/,其中涵盖了结构的基础知识。 –