Storing dynamic array reference which was passed through a function parameter
-
Play videoPlease edit your post.
For large amounts of code, attach it.
- 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.
WHRoeder:
-
Play videoPlease edit your post.
For large amounts of code, attach it.
- 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.
gszabo:
I believe it is possible, otherwise none of my indicators with buffers would work.
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.
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