📄 variable.cpp
字号:
/************************************************************************ Copyright IBMTC Written by Xinxi Wang**************************************************************************/#include <iostream>#include "Variable.h"using namespace std;Variable::Variable(){}Variable::Variable (const Variable& v){ name = v.name;}/** * @param name */Variable::Variable (string name ) : name(name){}/** * @return Type */Type Variable::getType ( ) const { return VARIABLE;}/** * @return bool * @param other */bool Variable::operator== (const Token& other ) const { if(getType() != other.getType()) return false; const Variable & v = dynamic_cast<const Variable &>(other); return v.getName() == name;}/** * @return string */string Variable::getName ( ) const { return name;}/** */ Variable::~Variable ( ){}/** * @brief 判断是否为变量名字 */bool Variable::isVariable (const string& v){ for(string::const_iterator it = v.begin(); it != v.end(); it++) if(!isupper(*it)) return false; return true;}/** * 拷贝 */Token *Variable::clone() const{ return new Variable(*this);}void Variable::print () const{ cout << name;}bool Variable::operator<(const Token & other) const{ if(getType() < other.getType()) return true; else if(getType() > other.getType()) return false; return name < dynamic_cast<const Variable &>(other).name;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -