You don't have a return statement in your function.
main() should be int main()
And you should check that iter or max is smaller than the vector size ( list.size() )
main() gives just a warning, a literal value is equal to returning that value. (Putting 0; as function content is the same as return 0;, so iter<max?list[iter]+sum(list,max,iter+1):list[max]; equals return iter<max?list[iter]+sum(list,max,iter+1):list[max];)
(Putting 0; as function content is the same as return 0;, so iter<max?list[iter]+sum(list,max,iter+1):list[max]; equals return iter<max?list[iter]+sum(list,max,iter+1):list[max];)
That's not true ISO/IEC 14882:2003 ยง6.6.3, 2:
Flowing off the end of a function is equivalent to a return with no value; this results in undefined
behavior in a value-returning function.