+ 1
Please Explain reason why output is Zero
I don't get why o/p 0. Please explain see answer for code I am talking about
5 odpowiedzi
+ 9
a=a;
b=b;
is ambiguous. The compiler reacted by assigning the value of the variables back to themselves instead of assigning the parameters to the local variables in class Program.
Fix this by simple renaming the parameters. E.g.
Program(int x, int y)
{
a = x;
b = y;
}
+ 7
Ah, yes. I missed that. 'this' would be able to specify which variable to use.
+ 3
Thanks Hatsy.
It seems we can use *this* keyword too.
0
This is because there is no input bull the user nor the values of the variables initialized
Hence,the out put is zero
the comp. takes a as 0 as well as b 0 therefore sum is 0