Hi guys
What's the default pointer value in c++? Can I count on the compiler to set an uninitialized pointer to NULL? Is it compiler dependant? What's the "consensus"?
Thanks!
-FH
Hi guys
What's the default pointer value in c++? Can I count on the compiler to set an uninitialized pointer to NULL? Is it compiler dependant? What's the "consensus"?
Thanks!
-FH
It really depends somewhat on how you declare your pointer. For example, a static or global pointer will be default initialized to null. A local pointer will contain random garbage if not explicitly initialized, just like any other local variable.
Best practice is to initialize your variables in all cases to avoid having to remember and apply the different rules to the given situation.
Hi thank you very much for the quick and concise reply :)
-FH
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.