calling a function error

solved
Last edited on
Speaking only of the code above, get_int_ref(int& n) returns nothing. It does not return any values.

n = get_int_ref(); So what are you trying to make n equal to?


Also, get_int_ref(int& n) accepts a parameter, so why are you trying to call it with no parameters?


Last edited on
Your prototype of int get_int_ref() does not declare the function void get_int_ref(int& n).
Technically you declare one function get_int_ref() and define one function get_int_ref(int& n) and your main won't know the later since it is defined after main.

You have to declare it with the parameter types it has.

 
void get_int_ref(int&);


Next you should be consistent if you want to pass by refence of by value
1
2
n = get_int_ref(); //by value with      int get_int_ref();
get_int_ref(&n); //by reference with  void get_int_ref(int& n); 


And last for now you can't parse a number in an input string like you do.
Read atoi for that. http://www.cplusplus.com/reference/cstdlib/atoi/?kw=atoi
Last edited on
Topic archived. No new replies allowed.