Reputation: 83
This is one function in .h file
LinkedListElement<char> * findLastNthElementRecursive(int n, int ¤t);
Try both
findLastNthElementRecursive(3,0);
and
int a = 0;
findLastNthElementRecursive(3,&a);
error is no matching function
I GOT IT findLastNthElementRecursive(3,a);
SHOULE BE THIS WAY
but if I do not want to create new variable like a, how to do that?
Upvotes: 1
Views: 44
Reputation: 258648
A temporary cannot bind to a non-const
reference. In your first case, you attempt to pass a temorary as parameter, and it fails.
The second one doesn't work because &a
is the address of a
, effectively an int*
, so doesn't match the signature of the function.
The correct way would be
int a = 0;
findLastNthElementRecursive(3,a);
Upvotes: 3
Reputation: 500883
Try:
int a = 0;
findLastNthElementRecursive(3, a);
Also note that you're ignoring the return value of findLastNthElementRecursive()
.
Upvotes: 1