Error: Expression must have (Pointer-to-) function type
13,970
Solution 1
Unlike in math, the multiplication operator *
can't be omitted. Change
k(SecondStirling(k,n-1))
to
k * (SecondStirling(k,n-1))
Solution 2
By writing
k(SecondStirling(k,n-1))
You are trying to call a function named "k", or pointed by "k", accepting a single parameter of type int (which is returned by SecondStirling). However "k" is an int variable, hence the error. The correct syntax, as already pointed out, is
k * (SecondStirling(k,n-1))
Author by
Admin
Updated on June 04, 2022Comments
-
Admin almost 2 years
I am writing a function that spits out what are called Stirling numbers. The code that I've written is as follows:
int SecondStirling(const int& k, const int&n){ if(k<0||n<0) return 0; if(k==0 && n>0) return 0; if(k>0 && n==0) return 0; if(k>n) return 0; if(k==n) return 1; else return k(SecondStirling(k,n-1))+SecondStirling(k-1,n-1); }
However, I am getting an error on the last line: Error: Expression must have (Pointer-to-) function type, the error specifically referring to k. What gives?