Your compiler should, at least with suitable options, be able to make a comment similar to:
In member function 'int test::sumf1(int, int)':
27:18: warning: 'x' is used uninitialized in this function [-Wuninitialized]
27:18: warning: 'y' is used uninitialized in this function [-Wuninitialized]
You, in turn, should pay attention to the feedback that the compiler gives.
Thats becuase your functions doesnt make any sense.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
int test::sumf(int x, int y)
{
int z;
z = x + y;
return z;
}
int test::sumf1(int p, int q)
{
int r, x = 0, y = 0;
r = (p - q) + sumf(x, y);
return r;
}
You call sumf and send in x and y. x and y are 0. Then you do z = 0 + 0. Which is still 0.