# Another C++ Error, an "operand has type double...' "



## Atnevon (Jul 2, 2008)

Hello Agian everyone. 

I'm not to sure what could be doing this, as to me, it looks right. This is another assignment for entry C++. I know I sound like a newb asking for help agian, but then agian, what are forums for at time lie this?

Now, I have to use value returning functions in this assignment. I need to have the functions as main(), getHoursWorked(), getPayRate(), and calcGross() all together to calculate someones paycheck for the week. 

So this sounds like a simple  "Pay = hours * rate", just a little overdone (if you ask me. Then again, I don;t know better at this point, so if I'm jumping the gun, please let me know)

So I get all my kinks worked out, except this one line where I do the calculations for calcGross(). I have 2 errors from my build log. They say this:

error C2296: '*': illegal, left operand has type 'double(_cdecl*)(void)' 
error C2297: '*': illegal, right operand has type 'double(_cdecl*)(void)' 



Now, I'm not sure why I'm getting this. My arithimtic setup looks correct to me, so why would I get this?

I'm using Microsoft C++ Visual Studio Express 2005 for reference.

Now for the moment of joy:
Thank you all for helping.

P.S. - I was not sure to post this in my last thread, or make a new one. I figured, well, new problem and situation, which altogether is a different topic, so new thread. If I am wrong, pleas correct me too. 



Source Code said:


> //Lab 3 by <<<<<<  ENTER NAME HERE   >>>>>>>>>
> //ITCS 1214
> 
> #include <iostream>
> ...


----------



## Kreij (Jul 2, 2008)

Since you are calling functions shouldn't this line in  "calcGross()" look like ...

gross = getHourseWorked() * getPayRate();

Not great with C++, so just a guess. You need to include the parenthesis in C# when calling a function.
I think when  you exclude the parenthesis you are accessing a pointer to the function instead of calling it.
Or something like that


----------



## Atnevon (Jul 2, 2008)

Tried the parenthesis, and got this:


----------



## Kreij (Jul 2, 2008)

That's because you are declaring calcGross with two input parameters and not calling it with any in main().

Since you are calling the two functions from within calcGross, just declare it as

```
double calcGross()
{
    double gross = 0.0;
    gross = getHoursWorked() * getPayRate();
    return gross;
}
```


----------



## Atnevon (Jul 2, 2008)

Kreij said:


> That's because you are declaring calcGross with two input parameters and not calling it with any.
> 
> Since you are calling the two functions from within calcGross, just declare it as
> 
> ...



Kreij, I love you so much.

I tweeked that and my main () and finally got it. Now I see what my error was. I was treating the calcGross like an a magic task, and not a value returning function like getHours and getRate.

I guess what you suggested just pushed me to fix it. You may have nudged me answer, but it helped me to understand my error and learn the concept. BAM!! Once agian, learning has occured. Thank you so much, and here is the pretty result:



 Success!!!!!   ^_^ said:


> //Lab 3 by
> //ITCS 1214
> 
> #include <iostream>
> ...


----------



## Kreij (Jul 2, 2008)

If you want to lighten the code a bit consider the following ...


```
double calcGross()
{
    double gross;  // no need to give it a value
    return gross = getHoursWorked() * getPayRate();
}
```

Saves a little typing !

also ...

```
int main()
{
    cout << fixed << setprecision(2) << "Total Pay for Week = $" << calcGross() << endl;
    return 0;
}
```

No need to have totalPay variable at all then.

Good job !!


----------



## Kreij (Jul 2, 2008)

Oh ... and a couple of comments on what you posted ...


> I know I sound like a newb asking for help agian, but then agian, what are forums for at time like this?


That is exactly what we are here for. Never be afraid to ask. No question is too basic.
No one is born knowing how to program, and you have to start somewhere.



> P.S. - I was not sure to post this in my last thread, or make a new one. I figured, well, new problem and situation, which altogether is a different topic, so new thread. If I am wrong, pleas correct me too.



New thread for new problem is fine as long as you are not just making a new thread to continue an existing problem



> Kreij, I love you so much.


If you are a guy ... we have may have problems.
If you are a girl ... Mrs. Kriej may have problems


----------

