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"?


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 :)