title: Call constructor to initialize variables
body: <p>I have the following class definition in C++ :</p>
  
  <pre><code>class foo {
  private:
     int      a,b,c;
  
     foo();     // constructor
     void     setup(int x, int y);
     void     some_function_that_changes_a_b_c();
  }
  
  
  foo::foo() {
     a = b = c = 0;
  }
  
  void foo::setup(int x, int y) {
      foo();    // &lt;-- I use this to make sure a,b,c are initialized
      a = x;
      b = y;    // &lt;-- c is left unchanged!
  }
  
  void foo::some_function_that_changes_a_b_c() {
      // here's some code that changes variables a,b,c
  }
  </code></pre>
  
  <p>And then I have a code that uses this class:</p>
  
  <pre><code>foo  *a = new foo;
  a-&gt;setup(1,2);
  a-&gt;some_function_that_changes_a_b_c();
  a-&gt;setup(5,7);   // &lt;-- HERE IS THE PROBLEM
  </code></pre>
  
  <p>The problem is that on the second call to setup(), it doesnt run the foo() constructor to reset my values or a,b,c , so the c variable stays with the old value it was on the call to some_function_that_changes_a_b_c(), I tested this with the debugger and it seems like on the second call, foo() is addressing a different memory space for the variables.</p>
  
  <p>Is there a way to fix this?</p>