Avatar of Chris Pfeiffer
Chris Pfeiffer
Flag for Japan asked on

Compile Error

I am sure this is easy, I am trying to explore C++ using random websites and can not figure out why this will not compile.

I get the compile error at error C2660: 'SubExpression::parse' : function does not take 1 arrgument.

Thanks in advance

I have included subexpression as well
#include <iostream>
#include <fstream>
#include <strstream>
#include <string>
#include <vector>
using namespace std;

#include "expression.h"
#include "subexpression.h"
#include "symboltable.h"
#include "parse.h"

SymbolTable symbolTable;

void parseAssignments(strstream& in);

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;
        strstream in(line, SIZE);
        in >> paren;
        cout << line << " ";
        try
        {
            expression = SubExpression::parse(in); 
            in >> comma;  
            parseAssignments(in);
            double result = expression->evaluate();
            cout << "Value = " << result << endl;    
        }
        catch (exception& e)
        {
              cout << "Standard exception: " << e.what() << endl;
        }
        
    }
    return 0;
    
}

void parseAssignments(strstream& in)
{
    char assignop, delimiter;
    string variable;
    double value;
    do
    {
        variable = parseName();
        in >> ws >> assignop >> value >> delimiter;
        symbolTable.insert(variable, value);
    }
    while (delimiter == ',');
}

Open in new window

#include <iostream>
using namespace std;

#include "expression.h"
#include "subexpression.h"
#include "operand.h"
#include "plus.h"
#include "minus.h"
#include "times.h"
#include "divide.h"

SubExpression::SubExpression(Expression* left, Expression* right)
{
    this->left = left;
    this->right = right;
}

Expression* SubExpression::parse()
{
    Expression* left;
    Expression* right;
    char operation, paren;
    
    left = Operand::parse();
    cin >> operation;
    right = Operand::parse();
    cin >> paren;
    switch (operation)
    {
        case '+':
            return new Plus(left, right);
        case '-':
            return new Minus(left, right);
        case '*':
            return new Times(left, right);
        case '/':
            return new Divide(left, right);
    }
    return 0;
}

Open in new window

C++

Avatar of undefined
Last Comment
Chris Pfeiffer

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
jkr

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Chris Pfeiffer

ASKER
Man, its time to go to sleep.. Thanks for that, as soon as I read it I wondered how I missed it..
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck