I would like to know what the code which is followed by a base class constructor does. Here is the code:
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
class Person
{
public:
Person() : name(""), age(0) {}
protected:
string name;
int age;
};
class Student : public Person
{
public:
Student() : Person::Person() {}
private:
int student_id;
};
I know what the code does in class Person
:
Person() : name(""), age(0) {}
But I do not understand what this line does in class Student
:
Student() : Person::Person() {}
So what it the meaning of Person::Person()
after the colon?