title: If statement inside Struct Declaration C++
body: <p>I have a doubt regarding structs and if statements in C++</p>
  
  <p>For the sake of simplicity, I have created a sample code to explain my intention</p>
  
  <pre><code>int var = 10
  
  struct example{
      int a;
      int b;
      if(var &gt; 8){
          int c;
      }
  };
  </code></pre>
  
  <p>I have a codebase which uses similar kind of code as above. Commenting out the if portion does not give any errors.
  My question is</p>
  
  <ul>
  <li>Could if statements be put in struct declarations?</li>
  <li>If not, what is the possible remedy for this, since if statment is mandatory.</li>
  </ul>
  
  <p>Note: I cannot use #if,#else directives nor std::optional or other standard libraries to mitigate this, so please help me find another solution.</p>