Look at what the embedded compiler (the gear icon to the upper right of your source code) has to say about your code:
9:26: error: ISO C++ forbids declaration of 'payincar' with no type [-fpermissive]
10:26: error: ISO C++ forbids declaration of 'nopaycar' with no type [-fpermissive]
11:43: error: ISO C++ forbids declaration of 'display' with no type [-fpermissive]
17:37: error: ISO C++ forbids declaration of 'payincar' with no type [-fpermissive]
In member function 'int tollbooth::payincar(std::string)': 22:1: warning: no return statement in function returning non-void [-Wreturn-type]
At global scope: 23:37: error: ISO C++ forbids declaration of 'nopaycar' with no type [-fpermissive] In member function 'int tollbooth::nopaycar(std::string)': 27:30: error: expected primary-expression before '&' token
27:32: error: 'fileout' was not declared in this scope
27:48: error: expected primary-expression before 'answer'
37:13: error: a function-definition is not allowed here before '{' token 39:1: error: expected '}' at end of input
39:1: warning: no return statement in function returning non-void [-Wreturn-type] |
So start with the first error on line 9:
payincar (string answer); //increments the car total and adds .50 to the cash total
You must tell the compiler what this function is going to be returning. For example void, int, double. (
void payincar(string answer);
).
Your member functions must also have a return type:
void tollbooth::payincar (string answer) {
and your definition and function must both agree with the return type.
Once you fix all the member function definitions and functions you will still have at least one missing ending brace '}' for one of your member function definitions.
Lastly you're still trying to use the assignment operator like it was the comparison operator:
while (!answer = 'q');
There are a couple of things wrong here. First answer is a string, the compiler won't know how to negate a string (!answer). The second thing wrong is that your using the assignment operator= when you should be using the comparison operator==. The last thing wrong is that you're trying to assign (or compare) a string to a character const ('q'). In C++ character constants use the single quotation marks ' ' and a string constant uses double quotation marks " ". So this line should look more like:
while(answer != "q");
and don't forget that C++ is case sensitive "q" is not the same as "Q".