Storing dynamic array reference which was passed through a function parameter

Back to topics list To post a new topic, please log in or register
avatar
14
gszabo 2015.06.29 09:04
 

Hello,

does somebody know if it can be stored the value of a reference parameter which passes a dynamic array reference. Example:

class AAA
{
   ??? Buffer;

   void method_A(const double & buffer[])
   {
      Buffer = buffer;
   {

   double method_B(int idx)
   {
      return Buffer[idx];
   }
};

void Proc()
{
   AAA a = new AAA();
   
   a.method_A(Close);
   double x = a.method_B(20);
}

Thanks

Gabor

avatar
1109
Ovo 2015.06.29 11:58 #
 
No, you cannot. What you can is defining the array inside an object and passing the object as a parameter. Just pay attention to its life cycle (its definition scope).
avatar
13000
WHRoeder 2015.06.29 13:28 #
 
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. Mt4 doesn't have pointers to POD, only pointers to a classes.
    class Buffer{
     public:
       TYPE buffer[];
    }
    class AAA
    {
       Buffer* buffer;
    
       void method_A(/*const*/ Buffer& buffer)
       {
          buffer = GetPointer(buffer);
       {
    
       double method_B(int idx)
       {
          return buffer.buffer[idx];
       }
    };
    Also Don't use const, as constant upcast won't compile [(const TYPE*)p] and koenig lookup is broken.

avatar
14
gszabo 2015.06.29 14:04 #
 
WHRoeder:

  1. Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. Mt4 doesn't have pointers to POD, only pointers to a classes.Also Don't use const, as constant upcast won't compile [(const TYPE*)p] and koenig lookup is broken.

Thanks everybody, this is what I was afraid of. But with using struct I can't store the reference of Close, Open, High, ... or any of the indicator buffers.

avatar
1109
Ovo 2015.06.29 15:25 #
 
gszabo:

Thanks everybody, this is what I was afraid of. But with using struct I can't store the reference of Close, Open, High, ... or any of the indicator buffers.

I believe it is possible, otherwise none of my indicators with buffers would work.
Back to topics list  

To add comments, please log in or register