c++ - Calling a Function error in Visual Studio 2015 -


update: okay, everyone! textbook says function prototype requires functions declared in parenthesis, , examples shown different code in function header , function body, so.. went showing me. corrected suggestion of leaving prototype's parenthesis empty , worked.

for record, genuinely hate these textbooks... thank y'all again help!

op: i'm getting error:

c2660 'getletter': function not take 0 arguments.

the code this:

#include <iomanip> #include <iostream> #include <cmath> using namespace std;  char getletter(char letter);  int main() {     char firstletter = getletter();         cout << firstletter;     return 0; }   //end of main function  char getletter() {     char letter = ' ';     cout << "enter character: ";     cin >> letter;     return letter; }   // end of getletter function 

my code looks example given in book, none of examples use "char" function, use double or int; not sure if matters. error (on line 12, bottom of main function) code written instructor, not i, makes more confusing me. i'm having trouble grasping lesson , need second viewpoint.

your function declaration statement accepts char:

char getletter(char letter); 

if want change no longer requires char parameter, use this:

char getletter(); 

why:

your function signatures must same function definitions , function calls.


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -