It is not valid memory, at any time some other program can overwrite the memory and therefore the pointer points to bad memory. This is something you will have to consider when using pointers. This can be shown with this little example:
Code:
#include <iostream>
using namespace std;
class Foo
{
public:
Foo() { cout << "Foo constructor" << endl; }
~Foo() { cout << "Foo destructor" << endl; }
};
int main()
{
Foo* bar;
{
cout << "New scope" << endl;
Foo temp;
bar = &temp;
cout << "Back to main scope" << endl;
}
cout << "In main scope" << endl;
// Now bar points to bad memory and should not ever be used here without being reassigned to different memory
cin.get();
}