title: C++: how to make getters and setters work with an empty constructor
body: <p>First of all, I have only learned a little bit of Java before. It's been only a few days since I started getting friendly with C++ so please don't take this question so basic and please don't degrade my question.</p>
  
  <p>I made a simple source code as follows:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  class Car {
      public:
          void setBrand(string name);
          void setPrice(double price);
          string getBrand();
          double getPrice();
          Car();
          Car(string name);
          Car(string name, double price);
  
      private:
          string name;
          double price;
  };
  
  Car::Car() {
  }
  
  Car::Car(string name) {
      name = name;
  }
  
  Car::Car(string name, double price) {
      name = name;
      price = price;
  }
  
  void Car::setBrand(string name) {
      name = name;
  }
  
  void Car::setPrice(double price) {
      price = price;
  }
  
  string Car::getBrand(void) {
      return name;
  }
  
  double Car::getPrice(void) {
      return price;
  }
  
  int main() {
      Car car;
      car.setBrand("Nissan");
      car.setPrice(30000);
      cout &lt;&lt; "Brand: " &lt;&lt; car.getBrand() &lt;&lt; endl;
      cout &lt;&lt; "Price: " &lt;&lt; car.getPrice() &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p>I wanted to make a code that creates an empty instance of a class called Car, set the field values later and print them out on the console.</p>
  
  <p>The code did not make any errors during the compile, but the result I see was totally different from what I expected. It didn't show the brand name and the price was looking even weird, as follows.</p>
  
  <pre><code>Brand: 
  Price: 6.95322e-310
  </code></pre>
  
  <p>Somebody help me out! Thank you very much indeed in advance.</p>