Assuming a definition like this,
void CConfigTest::OnSelchangedTree(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
TVITEM item = pNMTreeView->itemNew;
// find the session of the selected item
if(item.hItem != NULL)
{
HTREEITEM root, parent, node;
node = item.hItem;
parent = m_treeSM.GetParentItem(item.hItem);
root = m_treeSM.GetRootItem();
while(parent != root && parent != NULL)
{
node = parent;
parent = m_treeSM.GetParentItem(parent);
}
MyCommand* pCmd = (MyCommand*)(m_treeSM.GetItemData(node));
....
开发者_如何学运维 ....
I tried these statements below, but failed.
pCmd->subList[2]
(pCmd->subList)[2]
How can I get the array member values(such as subList[2]). I want to replace the value of subList[2] with other same type value. Thank you.
Lists do not support random access. You need to switch to another container type which does, or iterate over the list until you reach the element you want.
If you want to array like behavior and use the subscript operator you should use std::vector
and not std::list
. Then you can use it just like an array for accessing and replacing elements.
精彩评论