//+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ struct SStruct { int x,y; void Init(int X,int Y) { x=X; y=Y; } void Init(SStruct &s) { x=s.x; y=s.y; } }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ struct SStruct1 { int x,y; void SStruct1() { } void SStruct1(int X,int Y) { x=X; y=Y; } void SStruct1(SStruct1 &s) { x=s.x; y=s.y; } }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OnStart() { //--- 1 SStruct s1={1,2}; //--- 2 SStruct s2; s2.Init(1,2); //--- 3 SStruct s3; s3.Init(s2); //--- 4 SStruct1 s4; s4.x=1; s4.y=2; //--- SStruct1 s5(1,2); //--- SStruct1 s6(s5); } //+------------------------------------------------------------------+

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
Hi,
is there a way to initialize a struct within a function call. Does it work only for classes?
thank you
Daniel