Forums Register Login

initailzation

+Pie Number of slices to send: Send

+Pie Number of slices to send: Send
think about local variables, they don't initialize with default value.
+Pie Number of slices to send: Send
thats because you did not initialize x.
+Pie Number of slices to send: Send
i know this rule guys but why is if(b=true) different from if(true) to the compiler?
+Pie Number of slices to send: Send
cant the compiler see that b is a boolean and true is being assigned to it?
+Pie Number of slices to send: Send
if(b=true) means => compiler not sure at the compile time whether the body of this if will execute or not!
if(true) means => compiler knows the body of if is gonna execute while running the program.
+Pie Number of slices to send: Send
or in other words, the true literal is a compile time constant. The value returned by an assignment, is not a compile time constant, even though the variable is being assigned to a compile time constant.

Henry
Hang a left on main. Then read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 768 times.
Similar Threads
short-circuit question
if and while
Expected output is incorrect!
Doubt in Sun's 1.4 Practice xam
The strange ways of compile time constants
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 15:19:45.