varlist.cpp

来自「此程序实现了表达式求值」· C++ 代码 · 共 67 行

CPP
67
字号
// varlist.cpp

#include <stdio.h>
#include <assert.h>
#include <windows.h>
#include "varlist.h"

////////////////////////////////////////////////////////////////////////////
// CVarType
CVarType::CVarType() : type(VAR_INT), iValue(0), fValue(0.0)
{
	lstrcpy(name, _T(""));
}

CVarType::CVarType(const TCHAR* str, int t, int i, double f)
: type(t), iValue(i), fValue(f)
{
	assert(str != NULL);
	lstrcpy(name, str);
}

CVarType::CVarType(const CVarType& vl)
: type(vl.type), iValue(vl.iValue), fValue(vl.fValue)
{
	lstrcpy(name, vl.name);
}

CVarType::~CVarType()
{
}

CVarType& CVarType::operator =(const CVarType& vl)
{
	if(this == &vl)
		return *this;

	type = vl.type;
	iValue = vl.iValue;
	fValue = vl.fValue;
	lstrcpy(name, vl.name);

	return *this;
}

double CVarType::GetValue()const
{
	double ret = 0.0;

	if(VAR_INT == type)
		ret = (double)iValue;
	else if(VAR_FLOAT == type)
		ret = fValue;

	return ret; 
}

////////////////////////////////////////////////////////////////////////////
// CVarList
CVarList::CVarList() : m_iVar(0)
{
}

CVarList::~CVarList()
{
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?