从list列表取一个地址,通过传指针传到外面使用的例子
1.函数的写法
bool CTradeData::GetOneSymbolInfoFromAllSymbol(CString symbol,DATA_SYMBOL** pSymbolInfo)
{
BOOL bRet = FALSE;
SYMBOL_LIST::iterator it = m_symbolList.begin();
for ( ; it != m_symbolList.end() ; it++ )
{
if ( it->symbol == symbol )
{
*pSymbolInfo = &(*it);
bRet = TRUE;
break;
}
}
(*pSymbolInfo)->symbol = symbol;
ParseSymbolInfo(*(*pSymbolInfo));
return bRet;
}
2.外面调用
DATA_SYMBOL *pSymbolInfo = NULL;
if ( GetOneSymbolInfoFromAllSymbol(pPos->symbol,&pSymbolInfo) )
{
}