title: How to make a variable in a struct variable that is not inputted but set based on previous variables' values
body: <p>I am making a program which inputs fractions and puts them in order. I used struct to define a fraction type. I think I am making a type that initializing 2 variables(the numerator and the denominator of the fraction) and initializing the double type variable called value to a / b in this code:</p>
  <pre><code>struct fraction {
      int a; // numerator
      int b; // denominator
      double value = a / b; // floating point value of fraction
      bool operator &gt; (const fraction &amp;a) {
          fraction ans;
          return ans.value &gt; a.value;
      }
      bool operator &lt; (const fraction &amp;a) {
          fraction ans;
          return ans.value &lt; a.value;
      }
  
  };
  
  
  
  int main() {
  //---------logging-------
      fraction ratio = {1,2};
      cout &lt;&lt; ratio.value;
  //-----------------------
      // outputs 0
      // other things down here that is not included
  }
  </code></pre>
  <p>but apparently, that is not the case because I also need to initialize value. I figured out why, but the problem is, how can I make the variable without initializing it at the creation of the fraction? Thanks!</p>