RSS Forums RSS
Please support our C++ advertiser: Programming Forums
Views: 1543 | Replies: 8 | Solved
Join Date: Jun 2006
Location: USA
Posts: 1,082
Reputation: Duki has a spectacular aura about Duki has a spectacular aura about Duki has a spectacular aura about 
Rep Power: 7
Solved Threads: 4
Duki's Avatar
Duki Duki is offline Offline
Veteran Poster

Help User-Defined Function - part 2

  #1  
Apr 4th, 2007
Hey everyone, this is a big one.

The question has asked that I define functions and then write the function main to test the functions I wrote. I keep getting the following error at my first cout in main:

error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'void' (or there is no acceptable conversion)

I'm not sure what this is saying.
In addition, I need help with defining two of my functions and writing code to test them. They are as follows:

1. Write the definition of the function nextChar that sets the value of z to the next character stored in z.

2. Write the definition of the function funcOne that prompts the user to input a number. The function then changes the value of x to 2 times the old value of x plus the value of y minus the value entered by the user.

Now, with #2 I'm pretty sure I have the function defined right, though I don't know how to test it. #1 though, I have no clue how to define that function, though I did attempt it =/.

Could someone look through my code, and let me know if they notice any huge mistakes? This is our second chapter on user-defined functions, so I'm still learning about call by reference and whatnot. I have commented my code minimaly to assist you in finding the parts I'm having a tough time with.

Thanks guys! :mrgreen:

code:

  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std ;
  4.  
  5. void initialize ( int& , int& , char& ) ;
  6. void getHoursRate ( double& , double& ) ;
  7. double payCheck ( double& , double& ) ;
  8. void printCheck ( double , double, double ) ;
  9. int main()
  10. {
  11. int x ;
  12. int y ;
  13. int w ;
  14.  
  15. char z ;
  16.  
  17. double rate ;
  18. double hours ;
  19. double amount ;
  20.  
  21. cout << initialize( x , y , z ) << endl ; //error is here
  22. cout << getHoursRate() << endl ;
  23. cout << payCheck( hours , rate ) << endl ;
  24. printCheck( hours, rate, amount ) << endl ;
  25. cout << funcOne( w, x, y ) ; //confusion starts here
  26. cout <<
  27. }
  28.  
  29. void initialize ( int& x, int& y, char& z )
  30. {
  31. x = y = 0 ;
  32. z = ' ' ;
  33. }
  34.  
  35. void getHoursRate ( double& hours , double& rate )
  36. {
  37. cout << "Hours worked: " << endl ;
  38. cin >> hours ;
  39. cout << "Rate: &