How to resolve Unresolved Static Variable Error in MQL4/MQL5 for a struct array in an include file?

How to resolve Unresolved Static Variable Error in MQL4/MQL5 for a struct array in an include file?

Manage alerts

Loading saved threads...

aik3e · External communityPost link
External question — Stack Overflow Stack Exchange Author: aik3e Original post: https://stackoverflow.com/questions/67730554 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I have the following header/include file in mql4. struct SStruct { int mInt; }; class CMainClass { public: static SStruct Arr[]; }; class COtherClass { protected: void PrintArr(); }; void COtherClass::PrintArr(){ for (int i=0; i<ArraySize(CMainClass::Arr); i++){ PrintFormat("List[%i] = %i", i, CMainClass::Arr[i]); } }; //SStruct CMainClass::Arr = {0}; and the following is the error I am getting: unresolved static variable 'CMainClass::Arr' CodingPractice.mqh This attempt to initialize the array is producing even more errors: SStruct CMainClass::Arr = {0};
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External question — Stack Overflow Stack Exchange Author: aik3e Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/questions/67730554 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I have the following header/include file in mql4. struct SStruct { int mInt; }; class CMainClass { public: static SStruct Arr[]; }; class COtherClass { protected: void PrintArr(); }; void COtherClass::PrintArr(){ for (int i=0; i<ArraySize(CMainClass::Arr); i++){ PrintFormat("List[%i] = %i", i, CMainClass::Arr[i]); } }; //SStruct CMainClass::Arr = {0}; and the following is the error I am getting: unresolved static variable 'CMainClass::Arr' CodingPractice.mqh This attempt to initialize the array is producing even more errors: SStruct CMainClass::Arr = {0};

Cancel quote

Checking account access…