in the mql4 You cannot change strings "in place".
your "123456" belong to constant(!) string pool and both strings, a and b, refer to the same memory in the string pool
your "123456" belong to constant(!) string pool and both strings, a and b, refer to the same memory in the string pool
I understand that but this is not standard programming language behavior
#define section should be only exist in compile time not as constant in runtime.
string a = BUFFER;
string b = BUFFER;
should be compiled like (pseudo):
string a = new string(“123456”);
string b = new string(“123456”);
So “a” and “b” has different memory allocation!
Am I right? Will you change this in following versions?
Thanks, Ruby
#define section should be only exist in compile time not as constant in runtime.
string a = BUFFER;
string b = BUFFER;
should be compiled like (pseudo):
string a = new string(“123456”);
string b = new string(“123456”);
So “a” and “b” has different memory allocation!
Am I right? Will you change this in following versions?
Thanks, Ruby
what the standard do You mean? c++? or mql 4? please show me mql 4 standard
what the standard do You mean? c++? or mql 4? please show me mql 4 standard
I mean C++ standard

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
----------
MT4
----------
#define BUFFER "123456"
string a = BUFFER;
string b = BUFFER;
---------------------
c++ pesaudo code:
---------------------
void foo(char* pBuffer)
{
pBuffer[0] = 'X';
}
---------------
MT4 function:
----------------
void Test()
{
foo(a);
Print(a);
Print(b);
}
The output for both 'a' and 'b':
X23456
X23456
Which means: both 'a' and 'b' are using the same memory buffer!
Is it a compiler optimization to use same memory for constants(#define BUFFER "123456")?
Thanks