How to return a pointer from function

Hey,
I am trying to return a pointer from a method. Below is a sample of my code.
1
2
3
4
5
6
7
8
 CSubnode * CTest::GetSubNode()
{
  return m_psubnode;//this is declared in CTest as CSunbnode * m_psubnode
}

//in another class
m_subnode = m_ptest->GetSubNode(); //m_subnode is declared as a pointer


Is this the correct why to return a pointer?
Any help will be greatly appreciated!!
Yes, it is correct way to return a pointer. Watch out for possible invalidation if m_ptest will be destroyed before you use it.
Assuming m_ptest is type CTest* and m_subnode is type CSubnode* then yeah, that's right.
Topic archived. No new replies allowed.