title: Inheritence and construction in one object in C++
body: <p>I am studying inheritence in C++. I am trying to take all the informations in one object &quot;std1&quot; (without any more func. I managed to do it with other functions). I use construction methods but it gives error constantly. Can you help me?</p>
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  
  class Employee {
  protected:
      string name;
      string surname;
      string sex;
      int age;
      int ID;
  
  public:
      Employee(){
          this-&gt;name = &quot;null&quot;;
          this-&gt;surname = &quot;null&quot;;
          this-&gt;sex = &quot;null&quot;;
          this-&gt;age = 0;
          this-&gt;ID = 0;
      }
      Employee(string name, string surname, string sex, int age, int ID):name(name), surname(surname), sex(sex), age(age), ID(ID){}
  
      void changeInformations(string name, string surname, string sex, int age, int ID) {
          this-&gt;name = name;
          this-&gt;surname = surname;
          this-&gt;sex = sex;
          this-&gt;age = age;
          this-&gt;ID = ID;
      }
  
  
  };
  
  class Student :public Employee {
  public:
      int year;
      double GPA;
  
  
  
      Student(string name, string surname, string sex, int year , int GPA):Employee(name, surname, sex, age, ID),year(year), GPA(GPA){}
  
      void printStudent() {
          cout &lt;&lt; &quot;Name : &quot; &lt;&lt; name &lt;&lt; endl &lt;&lt; &quot;Surname : &quot; &lt;&lt; surname &lt;&lt; endl &lt;&lt; &quot;Sex : &quot; &lt;&lt; sex &lt;&lt; endl &lt;&lt; &quot;Age : &quot; &lt;&lt; age &lt;&lt; endl &lt;&lt; &quot;ID : &quot; &lt;&lt; ID &lt;&lt; endl &lt;&lt; &quot;Year : &quot; &lt;&lt; year &lt;&lt; endl &lt;&lt; &quot;GPA :&quot; &lt;&lt; GPA &lt;&lt; endl;
      }
  };
  
  
  int main()
  {
    
      Student std1(&quot;Kaan&quot;, &quot;ICYAR&quot;, &quot;M&quot;, 23, 50, 4, 3);
      std1.printStudent();
  
  
      return 0;
  }
  </code></pre>