I'm doing some C++ homework, it's for an online class, and my ****ing teacher never answers me back about questions I have. Ultimately I'm having to do it all on my own basically. I feel like I'm close with this one (or maybe not), but a little mixed up. I'm getting an "in function int main" error but don't know where, and "void value not ignored as it ought to be" error on the line: "totalCommission = calcCommission (commission1, commission2, commission3, commission4)". Can anyone help?
------------------------------------------------------------------------------------------------
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
I'm doing some C++ homework, it's for an online class, and my ****ing teacher never answers me back about questions I have. Ultimately I'm having to do it all on my own basically. I feel like I'm close with this one (or maybe not), but a little mixed up.
Use code tags when posting code.
First, even though this is valid syntax, move these definitions before main()
How can a function that returns "void" return a double (you assign the return value to a double called totalCommision)? It can't -- that's why you get an error.
Hopefully the fix should be obvious to you at this point.
First, please read the announcement "Before you Post". You need to post your code inside code tags so that it will retain the proper formatting. To put your code in code tags, type [ code] (without the space) then paste your code, then type [ /code] (again without the space).
Now to the problem, here's your code (in code tags) with my comments and the portions of your code they refer to in red:
Code:
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
// These three lines are function prototypes, and should not be inside the "main" function
// Also there is no body (implementation) of these functions, so any attempt to call them will
// result in an unresolved external
// Here you appear to be calling calcCommission, but there is no body for this function, so it will cause an
// unresolved external.
// Additionally, you are passing 4 variables into the function, but all of them are 0.0, so any calculations
// do on them will not give a valid answer.
// One other point here, your prototype for calcCommission says it returns a void - but this
// code is attempting to assign the return value to "totalCommission"
Bookmarks