Download MetaTrader 5

CList of CArrayInt how to?

To add comments, please log in or register
Liliput
512
Liliput  

Hi, i need help please.

I need a list whit CArrayInt objects. First i create it and then i want to use the arrays. Why when i do this i get no compilation errors but when it runs i get "incorrect casting of pointers".

What i do wrong?

Thx


   CList *list=new CList;
   //--- 
   if(list==NULL) 
     { 
      printf("List Object create error"); 
      return "List Object create error"; 
     } 
   //--- add elements=colums to list
   int ind=0;
   for(int i=0;i<tt_C-1;i++) 
     { 
      ind=list.Add(new CArrayInt);
      if(ind==-1) 
        { 
         printf("List Element addition error"); 
         delete list; 
         return "List Object create error"; 
        }
     }
   //---iterate TT
   for(int r=0;r<tt_R;r++)
     { 
      if(GetTT_Cell(r,tt_C-1)==1)
      {
         int cnt=0;
         for(int c=0;c<tt_C-1;c++)
         {
            cnt+=GetTT_Cell(r,c);
         }
         if(cnt>=1)
         {
            CArrayInt *object=list.GetNodeAtIndex(cnt-1);            
            if(object==NULL)  
              {  
               printf("Get node error");  
               delete list;
               delete object;
               return "Get node error";  
              }
            if(!object.Add(r))
              {
               printf("Element addition error");
               delete list;
               delete object;
               return "Element addition error";
              }
         delete object;
         }
      }
     }
  delete list;
To add comments, please log in or register