Using assignment operator +=

I have been working on an invoicing program for homework that must use the += operator. I have a function
void GetFee()
{
grandtotal+=totalcharge;
}

When calling the value from the main funtion though, I always get -9.25596e+061 or -1.#INF
I have also tried calling the value within the GetFee function but it always come up with the -9 number.
Sorry if this is a noob question, but it is driving me nuts.
That won't compile.
That depends, Galik. grandtotal and totalchange could be global variables.

Do you mind if we see the full source code, armored?

-Albatross
i am registered.. but where to post new topics?
@christopher

select forum (eg.Begginers)-->Press 'new topic' at the bottom of that page-->then let us discuss
Albatross wrote:
That depends, Galik. grandtotal and totalchange could be global variables.

I'm just trying to make the point that we can't do much given approximately one line of code and having to extrapolate the rest.
Galik wrote:
I'm just trying to make the point that we can't do much given approximately one line of code and having to extrapolate the rest.

Eh. True.

My post +1: Could we see your whole code, armored?

-Albatross
Normally you make such functions like this:
1
2
3
4
int GetFee(int grandtotal,int totalcharge)
{
return grandtotal+totalcharge;
}


And use them somehow like this:

1
2
3
int fee=GetFee(87,12); //two integer values as parameters, another int will be returned and written into fee.

std::cout<<"The fee is "<<fee<<std::endl; //output would be 'The fee is 99' 
Topic archived. No new replies allowed.