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

15th Apr 2020, 10:05 AM
Dakota
1 Answer
+ 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
15th Apr 2020, 10:13 AM
Stephan
Stephan - avatar