Hello kmheflin712,
Sometimes debugging the program is best done in small steps just like writing the program.
I decided to start with "main" and get as much as I could working. One of the things I noticed:
The names of the input and output files will be provided on the command line. As in:
a.out inputfile outputfile
|
I am wondering what "a.out" is here? Should this be the name of the program or is it something else?
This is required for the program, but you have not dealt with it yet. Since you have not mentioned what IDE you are using or how you are running the program I am not sure what you can do when you run the program for testing.
Then there is the "#include " files:
1 2 3 4 5 6 7
|
#include "expression.h"
#include "queue.h" // <--- Header file you wrote.
#include "stack.h"
#include <fstream>
#include <iostream>
#include <queue> // <--- STL header file. And why do you think you need it?
#include <string>
| |
The comment on line 6 needs to be answered.
Then you have:
std::queue<char> q; // <--- Do you know which "queue" you are using?
.
Then the code:
1 2 3 4 5 6
|
while (!exp.last)
{
fin >> exp;
q.push(exp);
q.push(exp);
}
| |
Has at least 3 problems.
First is the while condition. "last" is a private member variable of the class and thus not able to be accessed directly. You will need a public member functions to return the value of "last". I am think something like
while (!(exp.GetLast()))
. The () around the function call may be needed. I have not tested that part yet.
Next
fin >> exp;
. Here you are trying to read something into an entire class. Even if you opened the file stream in "binary" mode it still would not work. Not sure what your intention is here, but what you need is a "set" function to change the values of the private variables.
For
q.push(exp);
. Here "q" was defined as a "char", but you are trying to put an entire class into a a "char". This does not work. Since this does not compile I have not had the need to work on the next while loop.
I also noticed in the "expression.cpp" file you have:
1 2 3 4 5 6 7
|
#include <stack> // <--- STL header file. And why do you think you need it?
#include "expression.h"
#include <iostream>
#include <fstream>
std::stack<char> s; // <--- Do you know which "stack" you are using?
| |
Like using "<queue>" in "main" this is going to cause a problem.
Andy