Switch Conditionals in Functions not working???? - Printable Version +- Support Forums (https://www.supportforums.net) +-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87) +--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18) +---- Forum: Programming with C++ (https://www.supportforums.net/forumdisplay.php?fid=20) +---- Thread: Switch Conditionals in Functions not working???? (/showthread.php?tid=4462) |
Switch Conditionals in Functions not working???? - Equinøx - 01-22-2010 Hey everbody I am having a problem with a switch conditional which calls a function The function is Code: char FUNC_RACE_GOOD(); it is declared in the switch conditional like this Code: case '1': // Case for choosing the good alignment And end up here Code: char FUNC_RACE_GOOD() { // Function race good but all it does it completely skip the whole function call and just ends the program any help? RE: Switch Conditionals in Functions not working???? - MrD. - 01-22-2010 That's not how you call a function, you just use the name, no need to specify the return type when calling it, just do: Code: case '1': // Case for choosing the good alignment RE: Switch Conditionals in Functions not working???? - Fallen - 04-05-2010 yeah when calling a function, its name() will suffice. no need to add the data type RE: Switch Conditionals in Functions not working???? - Thirteen - 04-15-2010 Wouldn't you want the function to return something aswell? RE: Switch Conditionals in Functions not working???? - MrD. - 04-16-2010 The function would still return something, whether you choose to do anything with it is up to you. If you wanted the value that function returns you would just do: Code: char returned = FUNC_RACE_GOOD(); // Call the good race function, storing the return value in 'returned' |