添加using,switch case ,exception

当出现“找不到命名空间或缺少using ...”时,添加using:右键变量名,点“解析”。。。。

switch()括号里只能是整型值

exception首字母要大写:Exception

第一部份#include <iostream> #include <memory> #include <stack> #include <fstream> #include <vector> #include <cmath> #include <iomanip> #include <exception> #include <climits> #include <array> #include <cstdint> #include <string> using namespace std; class T { public: virtual bool isOperator() = 0; virtual ~T() {} }; class ValueToken : public T { public: long long value; long long get_value() { return value; } virtual bool isOperator() { return false; } explicit ValueToken(long long val) : value(val) {} }; class OperatorToken : public T { public: enum OpType { BGN = 0, END, ADD, MNS, NEG, MUL, DIV, POW, LBK, RBK } optr; virtual bool isOperator() { return true; } char get_char() { switch (optr) { case BGN: return '@'; case END: return '$'; case ADD: return '+'; case MNS: return '-'; case NEG: return '#'; case MUL: return '*'; case DIV: return '/'; case POW: return '^'; case LBK: return '('; case RBK: return ')'; default: return '?'; } } explicit OperatorToken(OperatorToken::OpType op) : optr(op) {} bool is_prior(const OperatorToken& r) { return prior_table[this->optr][r.optr]; } static bool prior_table[10][10]; }; bool OperatorToken::prior_table[10][10] = { //BGN, END, ADD, MNS, NEG, MUL, DIV, POW, LBK, RBK {0,0,0,0,0,0,0,0,0,0},//BGN {1,0,0,0,0,0,0,0,0,0},//END {1,1,0,0,0,0,0,0,1,0},//ADD {1,1,0,0,0,0,0,0,1,0},//MNS {1,1,1,1,0,1,1,1,1,0},//NEG {1,1,1,1,0,0,0,0,1,0},//MUL {1,1,1,1,0,0,0,0,1,0},//DIV {1,1,1,1,0,1,1,1,1,0},//POW {1,1,1,1,1,1,1,1,1,0},//LBK {1,1,0,0,0,0,0,0,1,0},//RBK };
最新发布
05-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值