Can you help me, explain question this, i dont understand it
How does C++ handles uninitialized variables?
thanks.
Can you help me, explain question this, i dont understand it
How does C++ handles uninitialized variables?
thanks.
It doesn't (unless the variable is a non-POD, in which case the defaut constructor is invoked).
Space large enough for the particular data-type is allocated on the stack, but consequently the value of that stack space is left unchanged. It is not zero or some common arbitrary value, it is whatever was there to begin with.
Try the following and see what you get:
Your output will be some seemingly random numbers, and it will differ from what I get, or anyone else gets.Code:#include <iostream> int main() { int num; std::cout << num << "\n"; return 0; }
thanks you, but can you detail it more
thanks all