// VarTable.cpp Dave Reed 9/30/03 //////////////////////////////////////////////// #include #include #include "VarTable.h" using namespace std; VarTable::VarTable() // constructor { // does nothing } void VarTable::Update(string varName, int varValue) // Assumes: varName is a variable name // Results: if already stored, corresponding entry in vals is set to varValue // otherwise, varName & varValue are added to vars & vals vectors { vars[varName] = varValue; } int VarTable::Lookup(string varName) // Assumes: varName is a variable name // Returns: if already stored, corresponding entry in vals is returned // otherwise, varName & 0 are added to vars & vals vector, returns 0 { if (vars.find(varName) == vars.end()) { vars[varName] = 0; } return vars[varName]; }