What is the default value for a pointer in Visual C++ 6.0.
If it matters my question refers particularly to variables on the stack.
In this case would myArray initially be a NULL pointer or would it have an undefined value?
double* myArray;
What is the default value for a pointer in Visual C++ 6.0.
If it matters my question refers particularly to variables on the stack.
In this case would myArray initially be a NULL pointer or would it have an undefined value?
double* myArray;
It is undefined. And even if VC++ 6.0 absolutely guaranteed to use a specific value, it would still be undefined by the C++ Standard. You should always avoid compiler specific features at all costs. You may not think now you need to move the code to another compiler, but sooner or later you will, and it will break.
And is it so hard to say:
double* myArray = NULL;
There is no default of a pointer in Visual C++ 6. If not declared, the pointer is not initialized, so the value will be undefined (meaning "garbage"). That's why it is recommended as best practice to initialize the pointers when declared (or in the initialization list of the constructor for pointers members of a class).
Undefined.
C++ doesn't define a default value for uninitialized pointers.
If you're running in debug with visual studio then the initial value of uninitialized variables is sometimes something like 0xcdcdcdcd. This value changes according to where the variable is - on the stack or on the heap. This is however not true in release builds and you must not rely on it in any way.
Here's some more information about these values.
The pointer is defined at run-time as occupying some certain location in memory. Its initial value will be defined by whatever bit-pattern just happens to be in that location. There is no way to determine it in advance.
As stated elsewhere, declare it with an initial value of null, or whatever is most convenient to you.