[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Compile Error

Posted on 2010-11-09
2
Medium Priority
?
633 Views
Last Modified: 2012-05-10
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

0
Comment
Question by:Chris Pfeiffer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 2000 total points
ID: 34097406
Well, as your snippet indicates, 'Expression* SubExpression::parse()' in fact take no arguments at all.

So, change

            expression = SubExpression::parse(in);

(line 37 in the 1st snippet) to read

            expression = SubExpression::parse();

and the error should go away.
0
 
LVL 2

Author Comment

by:Chris Pfeiffer
ID: 34097430
Man, its time to go to sleep.. Thanks for that, as soon as I read it I wondered how I missed it..
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question