Yes, you are right! Default constructor and destructor are generated if you did not declare.

When you just declare a node object (mynode), it is created on the stack. So when the function ends, the node object goes out-of-scope, thus it is destroyed. Therefore, the return value from CreateNodeWithData() is a pointer to a destroyed object (invalid pointer).

You can modify CreateNodeWithData() to create the node object from free-store using new keyword. In this case, you would have to use delete to destroy the object manually when not in use.

Code:
node* CreateNodeWithData( int data )
{
node* pNode = new node;
newnode->data = data;
newnode->next = null;
return pNode;
}

int main(void)
{
node* pNode = CreateNodeWithData(10);
delete pNode;
return 0;
}