Download MetaTrader 5

CString Class Copy Error

To add comments, please log in or register
sgfxtrader
54
sgfxtrader  

Hi!

I recently make a class inherited from CString.

Noticed that there is a copy string error.

Hope this will be help to you too!

// do not use void CString::Copy(string& copy) const -> It simply can't copy then.

void CString::Copy(string& copy)

  {
   // copy=m_string; // I suspect this is a coding error here.

   m_string = copy;

  }

Victor Kirillin
491
Victor Kirillin  

Method CString::Copy(string& copy) copies the string member to a string parameter.

Method CString::Assign(string& copy) copies the string parameter to a string member.

sgfxtrader
54
sgfxtrader  
uncleVic:

Method CString::Copy(string& copy) copies the string member to a string parameter.

Method CString::Assign(string& copy) copies the string parameter to a string member.

Dear uncleVic,

 

You are spot-on on this! Thank you for the enlightenment!

Should have read the CString class in detail and used Assign instead of Copy. 

The conventions could be confusing.

e.g: Assign/Copy vs Getter / Setter

I think it will be great if there is a similar practice for mql5 and java and c++.

 Thanks! 

To add comments, please log in or register