Download MetaTrader 5
To add comments, please log in or register
You sell neither signals nor apps? No problem, everyone can make profit!
whroeder1
13982
whroeder1 2015.02.17 13:14  
Ovo:

This part is a bit weird (inconsistent) from my point of view.

void add(Order& order)
{
.....
  orders[(size - 1)] = GetPointer(order);
}
 
Order* order = new Order();
....
orders.add(order);

 I would code it as

void add(Order* order)
{
.....
  orders[(size - 1)] = order;
}
They both do the same thing with your add(new). But the former allows the call to work with either a pointer or an instance.
Order globalOrder;
:
add(globalOrder);
as opposed to
Order globalOrder;
:
add( GetPointer(globalOrder) ); // Why does the caller need to know
                                // add internally stores a pointer?

I would code it thus:
void add(Order& order){ add( GetPointer(order) ); }
void add(Order* order) ...
        int pointer;
        int size;
       
        void OrderCollection()
        {
            pointer = -1;
            size = 0;
        }
Get in the habit of using initialization lists. Initialize once instead of default initialization and then assign.
        int pointer;
        int size;
       
        void OrderCollection()
                  : pointer(-1),
                    size(0)
                      {/*nothing more needs to be done*/}
Ovo Cz
2988
Ovo Cz 2015.02.17 13:49  
WHRoeder:


They both do the same thing with your add(new). But the former allows the call to work with either a pointer or an instance.as opposed to
I would code it thus:

I did not state it did not work. I have little use for collections with static instances, but if you have it different, I have no problem with it.
/ /12
To add comments, please log in or register