int input_num();
This declares a function called input_num
which returns an int
and takes no arguments. Informally called "the most vexing parse". The fact that C++ allows you to declare functions inside of the implementation of other functions only adds to the confusion.
scanf("%d",&input_num);
"%d"
means that you want to read into an int
, so you need to pass an int*
. &input_num
, however, is a function pointer (int (*)()
), as your compiler should have warned you. That's because specifying a function name without parentheses (input_num
) indicates a function pointer (and the address-of operator &
has no effect here because function pointers are different from all other pointers).
So this line would result in undesired behaviour anyway.
if(input_num==1) return;
else if(input_num==2)
Function pointers cannot be compared with int
s.
The solution to all these problems is actually making input_num
an int
and not a function:
int input_num = 0;
While you're at it, get rid of scanf
and use std::cin
.