Please support our C++ advertiser: Programming Forums
Views: 1543 | Replies: 8 | Solved
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:
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:
c++ Syntax (Toggle Plain Text)
#include <iostream> #include <iomanip> using namespace std ; void initialize ( int& , int& , char& ) ; void getHoursRate ( double& , double& ) ; double payCheck ( double& , double& ) ; void printCheck ( double , double, double ) ; int main() { int x ; int y ; int w ; char z ; double rate ; double hours ; double amount ; cout << initialize( x , y , z ) << endl ; //error is here cout << getHoursRate() << endl ; cout << payCheck( hours , rate ) << endl ; printCheck( hours, rate, amount ) << endl ; cout << funcOne( w, x, y ) ; //confusion starts here cout << } void initialize ( int& x, int& y, char& z ) { x = y = 0 ; z = ' ' ; } void getHoursRate ( double& hours , double& rate ) { cout << "Hours worked: " << endl ; cin >> hours ; cout << "Rate: &





