title: Why can this code not return the bpEffect variable with the value 505.5?
body: <p>The expected result from the following code should be 505.5, but instead it returns 3.97541e+70. Why is this the case and how can the problem be solved ?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  class Position {
  public:
      Position(int s, double p, string n) {
          shares = s;
          price = p;
          name = n;
      }
      double getBpEffect() {
          return bpEffect;
      }
  private:
      string name;
      int shares;
      double price;
      double bpEffect = (shares*price) / 2;
  
  };
  
  
  int main() {
      Position xyz = Position(100, 10.11, "xyz");
      double buyingPower = xyz.getBpEffect();
  
  
      cout &lt;&lt; buyingPower;
  
      system("pause");
      return 0;
  
  }
  </code></pre>