跳至内容

GetNodeAtIndex

GetNodeAtIndex

获取指定索引的列表项。

CObject*  GetNodeAtIndex(
   int  pos      // 位置
   )

参数

pos

[输入] 列表项的索引。

返回值

成功时是列表项的指针, NULL - 如果您未能获取指针。

例如:

//--- 例程 CList::GetNodeAtIndex(int)
#include <Arrays\List.mqh>
//---
void OnStart()
  {
   CList *list=new CList;
   //---
   if(list==NULL)
     {
      printf("对象创建错误");
      return;
     }
   //--- 添加列表元素
   //--- . . .
   CObject *object=list.GetNodeAtIndex(10);
   if(object==NULL)
     {
      printf("获取节点错误");
      delete list;
      return;
     }
   //--- 使用元素 
   //--- . . .
   //--- 不能删除元素
   //--- 删除列表
   delete list;
  }