|
| sethyra (3) | |||
| I'am just learning c++ (which is why Im in the beginner's section =P) so please pardon any nonconventional coding style I might have. I'm attempting to write a program that passes data by reference and I keep getting an error that disallows me to "convert from void to float" and I've no clue how to fix it. I found a similar post on the subject on this forum, but the user asking for assistance was using an array and that is over my head, so the help he received was non-transferable to me. =[ Any help would be much appreciated. Below is the code and errors. Im using Visual Studio 2008 Professional, if that matters any. Thank you! Oops I forgot to mention the error code in Visual Studio is pointing to lines 23 thru 26. ><
Error 1 error C2440: '=' : cannot convert from 'void' to 'float' ^ That is the error code I keep getting. | |||
Last edited on | |||
| sethyra (3) | |
| I tried changing the function type from void to float, but then the function has to return a value. My understanding, limited by lack of experience, is that a function can only return one value and I need to return multiple, which is why I was trying to "pass by reference" (I think that is the proper term, please correct me if Im wrong). Is there a way to pass by reference the data calculated in the doTheMath function to displayResults function? Because that would be wonderful =P Thank you! | |
Last edited on | |
| Bazzy (3179) | |
Since you pass your arguments as reference you don't need the sumAdd= part on lines 23-26, remove that.You actually need to call doTheMath only once | |
| sethyra (3) | |
| That worked! Thank you so much for your help. | |
Registered users can post in this forum.
