I am stuck at how to access the menu item

My menu has 5 items, the first one will have 5 subitems, and I am unable to access the subitems

CMenu* submenu=menu.GetSubMenu(0);
ASSERT(submenu->GetSafeHMenu()); // This line throws exception