title: C++ Constructor problems // Inherited class
body: <p>Initial problem solved. (which was a redefinition error)</p>
  
  <p>Furthermore, I don't know how to create a Student constructor which delivers the following:</p>
  
  <p>This is how I want my program / constructors to work:</p>
  
  <pre><code>//main.cpp
  Student s1(4015885);
  s1.print();
  Student s2("Test", "Student", 22, 5051022);
  s2.print();
  </code></pre>
  
  <p>The output should be as follows:</p>
  
  <pre><code>Standart
  Name
  18
  4015885
  
  Test
  Student
  22
  5051022
  </code></pre>
  
  <p>s1 works, but s2 doesn't work, because I don't have a fitting constructor</p>
  
  <p>This is my Person.h</p>
  
  <pre><code>#pragma once
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  class Person {
  
  public:
      Person(string name = "Standard", string surname =  "Name", int age**strong text** = 18);                              
  
      //GET
      //SET
      void print();
  
  protected:
      string name, surname;
      int age;
  };
  </code></pre>
  
  <p>Person.cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include "Person.h"
  using namespace std;
  
  Person::Person(string n, string s, int a) : name(n), surname(s), age(a)
  {
      cout &lt;&lt; "Person constructor" &lt;&lt; endl;
  }
  void Person::print() {
      cout &lt;&lt; name &lt;&lt; endl &lt;&lt; surname &lt;&lt; endl &lt;&lt; age &lt;&lt; endl &lt;&lt; endl;
  }
  </code></pre>
  
  <p>Student.h</p>
  
  <pre><code>#pragma once
  //#ifndef PERSON_H
  //#define PERSON_H
  #include "Person.h"
  
  class Student : public Person {
  public:
  
      Student(int matrikel_nummer);
  
      int get_matriculation_number();
  
      void set_matriculation_number(int matriculation_number) {
          this-&gt;matriculation_number = matriculation_number;
      }
  
      void print();
  
  private:
      int matriculation_number;
  
  };
  //#endif
  </code></pre>
  
  <p>Student.cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include "Student.h"
  using namespace std;
  
  Student::Student(int matrikel_nummer) : Person(name, surname, age)
  
  {
      cout &lt;&lt; "Student constructor" &lt;&lt; endl;
      this-&gt;matriculation_number = matriculation_number;
  }
  
  void Student::print() {
      cout &lt;&lt; name &lt;&lt; endl
              &lt;&lt; surname &lt;&lt; endl
              &lt;&lt; age &lt;&lt; endl 
              &lt;&lt; matriculation_number &lt;&lt; endl &lt;&lt; endl;
  }
  </code></pre>