0
C++: Initialization vs Assignment
I am curious if there is a difference between initializing a variable with a known formula, or assigning the formula to the variable later on in the code. I have an example code below to explain my question a little better. Any help would be appreciated. https://code.sololearn.com/c1DpSgDgT757
1 Odpowiedź
+ 1
Hi. The difference is in one extra assignment (for numbers default value is 0). In this case it doesn't make sense. But sometimes assignment after construction is unavailable(const variables), or there is no default value (references). I'll add examples later
https://code.sololearn.com/cF93B5Dl8HPV/?ref=app