The question that was put forth to me was:
What will the value of uninitialized variables be in C++? Do we have to initialize all variables? What would be the rule for initializing variables?
I've looked in my text as well as another text that I have on hand and can't seem to find the answer. Here's what I've attempted:
The value of uninitialized variables in C++ depends on the previous value stored in the memory that the uninitialized variable is assigned to. Initializing all variables is not a requirement, e.g. a variable does not need to be initialized if the variable will immediately be assigned a value via user input. Good programming practice should be to initialize a variable and if a variable is uninitialized, then comments should explain the reasoning behind leaving the variable uninitialized.
Am I missing something? Is their a resource anyone could point me to? Is there a "rule" to variable initialization that I missed? Thank you.