Download MetaTrader 5

Is it possible to make a struct with contain static variables

To add comments, please log in or register
Snelle Moda
613
Snelle Moda  

Hi

I try to make a struct with contains static variables but I get this error in the compiler:  

"struct has no members, size assigned to 1 byte"

"unresolved static variable "myData::Var1"

"unresolved static variable "myData::Var2"

"unresolved static variable "myData::counter"


Is it possible to store static variables in structures and if not, is there a solution for this problem. 

Or is the declaration of struct itself already a "static" combination of variables?  



struct MyData 
   { 
   static double Var1;    // 1e waarde 
   static double Var2;   // 2e waarde   
   static int    counter;  // Teller
   };

MyData Test = {0};
Snelle Moda
613
Snelle Moda  

Never mind.

I already fixed it.

This example solved my problem.


struct MyData 
   { 
   double Var1;     // 1e waarde 
   double Var2;     // 2e waarde   
   int    counter;  // Teller
   };

static MyData Test = {0};
To add comments, please log in or register