[急救]关于集合CARRAY
最近作一个小东西需要使用集合,类的定义如下
class MenuNode
{
virtual bool IsItem(void);
virtual bool IsList(void);
}
class MenuList : public MenuNode
{
bool IsItem(void){return false};
bool IsList(void){return true};
//list 的函数
}
class MenuItem : public MenuNode
{
bool IsItem(void){return true};
bool IsList(void){return false};
//item的函数
}
现,需要作一个CARRAY集合,里面可以存放MenuList和MenuItem的实例。
请问:
1.怎样才能定义符合这个要求的集合?
如:CArray <MenuNode*,MenuNode*> NodeArray;
2.怎样向集合中添加MenuList 和MenuItem 对象?
如:MenuNode *pNode = new MenuList();
NodeArray.add(pNode);
2.如何能够对集合中的数据进行编辑修改?
??=NodeArray.GetAt(0);
??.list(或item)的函数
需要急救,如果你了解,请提点建议,谢谢~~~
对不住各位了,我只有90的可用分了!!!
[解决办法]
使用你所列的操作方法就可以了 ~
[解决办法]
Add
Adds an element to the end of the array; grows the array if necessary.
GetAt
Returns the value at a given index