title: C++ Basic Constructor does not print out text
body: <p>I was just coding some basic C++, and I created a constructor inside a class. The constructor is meant to print out the name defined in the <code>main()</code> function, but for some reason when I run it, nothing happens. It's not really a huge problem, but I would like to find out why it doesn't work, so I know what to do later on!</p>
  
  <p>Code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  class ClassOne{
  public:
      ClassOne(string z){
          setName(z);
      }
      void setName(string x){
          name = x;
      }
      string getName(){
          return name;
      }
  
  private:
      string name;
  
  };
  
  int main()
  {
  ClassOne classOneObject("Hello World");
  cout &lt;&lt; classOneObject.getName();
  return 0;
  }
  </code></pre>