c++ function return

using namespace std;

class test{
int a = 0;

test* GetTest(){ }
int main(){

test* temp = GetTest();

temp is not NULL!! why?
Last edited on
why would it be?

you don't set anything to null anywhere.

temp is pointing to a random memory location; it may work and it may crash. If you want something to be null or any other value, you have to explicitly assign it that way. Here, get test would return null if you wanted temp to be null.

Topic archived. No new replies allowed.