Data loss while reading with cin

Hello everyone,
I'm new to C++ programming language and I need a help.
I'm trying to create a program which calculates the result of an entire math expression using a Last-In, First-Out algorithm (LIFO class), where is added a double value.
Correct me if I made a mistake, but I think that the problem lies in the template classes I've created. When debugging the code line-by-line, the arow disappear near cin statement and the program stop working after these messages in the debugger:

In std::istream::operator>>(double&) () ()
In std::istream& std::istream::_M_extract<double>(double&) () ()
#1 0x004018d0 in Entry::getExpression (this=0x22ff04) at G:\Codigo\HP\src\entry.cpp:148


G:\Codigo\HP\src\entry.cpp:148:4394:beg:0x4018d0
At G:\Codigo\HP\src\entry.cpp:148
Cannot open file: ../../../../src/gcc-4.7.1/libgcc/unwind-sjlj.c
At ../../../../src/gcc-4.7.1/libgcc/unwind-sjlj.c:127
Cannot open file: ../../../../src/gcc-4.7.1/libgcc/unwind-sjlj.c
At ../../../../src/gcc-4.7.1/libgcc/unwind-sjlj.c:129
Cannot open file: ../../../../src/gcc-4.7.1/libgcc/unwind-sjlj.c
At ../../../../src/gcc-4.7.1/libgcc/unwind-sjlj.c:132

Since I never can pass this line of the code, I couldn't test the rest of my code yet looking for logical errors.
I didn't included the entire code because it's too long.
Do anyone have any suggestions?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

//Entry.h
#include <iostream>
#include "LIFO.h"
#include "Calculator.h"
class Entry
{
    LIFO<double>* lifo;
    Calculator<double>* calculator;
    public:
        Entry();
        void getExpression();
        void makeOperation(char);
        double getExpressionResult();
        ~Entry();
};

//Entry.cpp file
  void Entry::getExpression()
{
    double val = 0;
    char mathCalc = ' ';
    do{
        //Check if next val is a digit
        if (  isdigit(cin.peek()) ){
            //The problem occurs here:
            cin >> val;

            //Add it to the queue
            this->lifo->addNode(val);
        } else if (cin.peek()){

            //Check if the next character is an math operator
            if (cin.peek() == '+' || cin.peek() == '-'  || cin.peek() == '*'  || cin.peek() == '/'  ){
                cin >> mathCalc;
            } else {
                throw (const char*)"Syntax error: unexpected value.";
            }
            this->makeOperation(mathCalc);
        }
        if (cin.peek() == ' ')
            cin.ignore();
        cout << "Executing iterator...";
    } while ( cin.eof() == false );
    cout << "Result: " << this->lifo->returnLastNode();
}
Topic archived. No new replies allowed.