Files
ScienceCalculator/ScientificCalculator/Calc.h
2025-07-01 16:04:35 +08:00

29 lines
573 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef CALC_H
#define CALC_H
#include"Tokenizer.h"
#include"InfixToPostfix.h"
#include"PostfixEval.h"
#include<optional>
#include<unordered_map>
using namespace std;
class Calc {
public:
//主接口函数:输入表达式字符串,返回计算结果
static double eval(const string& expresssion);
//安全接口带异常处理返回optional
static bool safeEval(const string& expr,double& res);
//调试函数打印token列表与后缀表达式
static void debug(const string& expr);
private:
static Tokenizer tokenizer;
static InfixToPostfix converter;
static PostfixEval evaluator;
};
#endif