Question
Hello. I am writing a program that evaluates expressions in C++ but I keep getting errors between my main class and the symboltable.h and .cpp
Hello. I am writing a program that evaluates expressions in C++ but I keep getting errors between my main class and the symboltable.h and .cpp classes. I am hoping another set of eyes can pick up something I haven't been able to for the past 12 or so hours. Thanks
//symboltable.h
class SymbolTable { public: SymbolTable(){} void insert(string variable, double value); double lookUp(string variable) const; void init();
private: struct Symbol { Symbol(string variable, double value) { this->variable = variable; this->value = value; } string variable; double value; }; vector
//symboltable.cpp
#include
#include "symboltable.h"
void SymbolTable::insert(string variable, double value) { const Symbol& symbol = Symbol(variable, value); elements.push_back(symbol); }
double SymbolTable::lookUp(string variable) const { for (int i = 0; i
void SymbolTable::init(){ if(elements.size()>0){ for(int i = elements.size(); i>0; i--){ elements.pop_back(); } } }
//main.cpp
#include
#include "expression.h" #include "subexpression.h" #include "symboltable.h" #include "parse.h"
SymbolTable symbolTable;
void parseAssignments(stringstream& cin);
int main() { const int SIZE = 256; Expression* expression; char paren, comma, line[SIZE]; string program;
ifstream fin("input.txt"); while (true) { symbolTable.init(); fin.getline(line, SIZE); if (!fin) break; stringstream cin(line, ios_base::in);
//cout > paren; cout > comma; parseAssignments(cin); cout evaluate()
void parseAssignments(stringstream& cin) { char assignop, delimiter; string variable; double value; do { variable = parseName(cin); cin >> ws >> assignop >> value >> delimiter; symbolTable.insert(variable, value); } while (delimiter == ','); }
Error List Entire Solution 35 Errors IA owamirgs 100Messages l#7 Build+ Intell sense Search ETor List CadDescripticn File Line Suppressian State 6 string undeclared identifier nreelhirtyProject Iwo ThracThirtyPraject Iwsybaltable.cpp ThraeThirtyProjecto symboltablecpp ThraeThirtyPrajectTasymbaltable.cpp IhreelhirtyProject Iwo syboltable cpp ThracThirtyPraject Iwsybaltable.cpp ThraeThirtyProjecto symboltablecpp ThraeThirtyPrajectTasymbaltable.cpp IhreelhirtyProject Iwo syboltable cpp ThracThirtyPraject Iwsybaltable.cpp ThraeThirtyProjecto symboltablecpp ThraeThirtyPrajectTasymbaltable.cpp IhreelhirtyProject Iwo syboltable cpp ThracThirtyPraject Iwsybaltable.cpp ThraeThirtyProjecto symkoltableh ThraeThirtyPrajectTasymbaltableh IhreelhirtyProject Iwo syboltableh ThracThirtyPraject Iwsybaltablo.h ThraeThirtyProjecto symkoltableh ThraeThirtyPrajectTasymbaltableh IhreelhirtyProject Iwo syboltableh ThracThirtyPraject Iwsybaltablo.h ThraeThirtyProjecto symkoltableh ThraeThirtyPrajectTasymbaltableh IhreelhirtyProject Iwo syboltableh ThracThirtyPraject Iwsybaltablo.h ThraeThirtyProjecto symkoltableh ThraeThirtyPrajectTasymbaltableh IhreelhirtyProject Iwo syboltableh ThracThirtyPraject Iwsybaltablo.h ThraeThirtyProjecto thirtyprajecttrwa.cpp ThraeThirtyPraject Taethirtyprcjectwa.cpp IhreelhirtyProject Iwo ethityprojecttwo.cpp ThracThirtyPraject Iwo ethityprajecttvo.cpp symboltable cpp 3 C2146 syntax emor. missingy befora idcntifier variable 2143 syntareor missing hefore *?447 .(': missing function header [ald-style formal list?) 3 CU6Ssrg undeclared identifier 3C2146 syntxeTor missingy befora identifier varisblo 2143 syntareor missing hefore C2447 : missing function header (ald-style fomal lis:) 3 CU6Selts: undaclaned identhier 3C2228 fof ze must hav class/stru/unian 3 C2065 elements: undaclared identidier C2228 eft of size must halss/ruct/union 3 CU6Selts: undaclaned identhier 3C2228 ft of pop back must have dlassistruct/urian * ? a061 symtar emor identifiar string C2061 yor. identifiar string 326 ntaxeor identfiar string 3C3646 ariabla: unknown Evrice spccifier * ? A430 missing type ipecifier int assumed. Note: C t t dnes not support cefault int 3C2143 yor missingh 30 missing type speciner-int assumed. Note:+does not support default-int 3 C2238 uncpacted tokensl prccading 3 C2029 variable not a member of SymblTable Symbol C2n65 undared identi fiar C2143 * ?A420 yntaeor missing hetoe missing type specifier it assumed. Note: C++ docs nat support cofaut int C238unexpacted tokensi prereding * ?2143 syntar emor missing .,' before . 30 missing type speciner-int assumed. Note:+does not support default-int *?2238 unexpacted token(s, preceding .: C209 inses undefined class 'std: basi ifstreamStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started