title: My setter doesn't work in new class (inheritance)
body: <p>This is my code. I created base class and in constructor set x=0. Next I used <code>virtual set_x() = 0</code>. And I created set_x() in new class. Output:</p>
  
  <p><code>set x</code> 
  <code>100</code>
  <code>DONE. Let's check.  0500</code></p>
  
  <p>Why I got 0500 not 100500?</p>
  
  <pre><code>#include "mainwindow.h"
  #include &lt;QApplication&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  struct invalid_file_handler : std::runtime_error{
      using runtime_error::runtime_error;
  };
  class base_class{
  private:
      int x;
      int y;
  public:
      virtual void set_x()=0;
      void set_y(){
          this-&gt;y=500;
      }
      int get_x(){
          return (this-&gt;x);
      }
      int get_y(){
          return (this-&gt;y);
      }
      base_class(){
        this-&gt;x=0;
        this-&gt;y=0;
      }
  };
  
  class new_class :public base_class{
  public:
      void set_x();
  private:
      int z;
      int x;
      int y;
  };
  
  void new_class::set_x(){
      cout &lt;&lt; "set x " &lt;&lt; endl;
      this-&gt;x=100;
      cout &lt;&lt; this-&gt;x &lt;&lt; endl &lt;&lt; "DONE. Let's check.  ";
  }
  
  int main()
  {
  
      ifstream my_open_file;
      string file_path = "/home/wojtek/Pulpit/elo.odt";
      try{
          my_open_file.open("/home/wojtek/Pulpit/elo.odt");
          my_open_file.close();
      }catch (std::runtime_error &amp;e){
          cerr &lt;&lt; "Hello Xd XD chua" &lt;&lt; endl;
          cerr &lt;&lt; e.what();
      }
      ofstream myfile;
      try{
      myfile.open ("/home/wojtek/Pulpit/example.txt");
      myfile &lt;&lt; "Writing this to a file.\n";
      myfile.close();
      }
      catch(invalid_file_handler &amp;e){
          cerr &lt;&lt; "Hello!" &lt;&lt; endl;
      }
      new_class *object = new new_class();
      object-&gt;set_x();
      cout &lt;&lt; object-&gt;get_x();
      object-&gt;set_y();
      cout &lt;&lt; object-&gt;get_y();
      //base_class object;
      //cout &lt;&lt; object.get_y();
  
      return 0;
  }
  </code></pre>