No matching constructor for initialization

I am converting a program from Java to C++ which involve me creating a dynamic array of objects. In my Vector class, I keep receiving an error saying, "No matching constructor for initialization of Student" on line 35. Any suggestions on how to rectify this error would be appreciated.

This is my Vector class:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include "Student.cpp"
#include <string>
#include <cstdlib>
#include <iostream>
#include <vector> 
using namespace std; 


class Vector
{
    // In CPP, you have to create a DYNAMIC array of DYNAMIC objects.
    // Otherwise, TA will deduct 35 points.
private:
    int capacity; //capacity of the current array
    int size;     // number of current records
    Student* list;
   // list = new Student[10];
public:
    Vector();
    ~Vector();
    int getCapacity();
    int getSize();
    int getIndex(int ID);
    Student get(int index);
    void print();
    bool add(Student newStudent);
    int remove(int productID);
};
Vector::~Vector(){}
Vector::Vector()
{
    // the initial array will have 2 elements
    capacity =2;
    size = 0;
    list = new Student[capacity];
}



int Vector::getCapacity()
{
    return capacity;
}
int Vector::getSize()
{
    return size;
}

int Vector::getIndex(int ID)
{
    int index = -1;
    for(int i=0; i<size; i++)
    {
        if( list[i].getID() == ID )
        {
            index = i;
        }
    }
    return index;
}

Student Vector::get(int index)
{
    return list[index];
}

void Vector::print()
{
    for(int i=0; i<size; i++)
    {
        //System.out.println( list[i].toString() );
        cout<<list[i].toString();
    }
}


//sonra
bool Vector::add(Student newStudent)
{
    bool result = true;
    int index = getIndex( newStudent.getID());
    if( index == -1 )
    {
        if( size < capacity)
        {
            list[size] = newStudent;
            size++;
        }
        else
        {
            //GROW
            capacity = capacity*2;
            Student* tmpList = new Student[capacity];
            for(int i=0; i<size;i++)
            {
                tmpList[i] = list[i];
            }
            list = tmpList;
            list[size] = newStudent;
            size++;
        }
    }
    else
    {
        result = false;
    }
    return result;
    
}

int Vector::remove(int productID)
{
    int result = 1;
    int index = getIndex( productID);
    if( index == -1)
    {
        result = index;
    }
    else
    {
        for(int i=index; i<size-1; i++)
        {
            list[i] = list[i+1];
        }
        size = size-1;
        // SHRINK
        if( size*2 == capacity )
        {
            capacity = capacity/2;
            Student* tmpList = new Student[capacity];
            for(int i=0; i<size; i++)
            {
                tmpList[i] =  list[i];
            }
            list = tmpList;
            size = capacity;
        }
        
    }
    return result;
}


Here is my Student class:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


#include <iostream>
#include <string>
#include "Person.cpp"

using namespace std;


class Student : public Person
{
private:
    string major;
    int collegeYear; // 1 freshman 2 sophomore 3 junior 4 senior
    
public:    
    Student(int ID, string firstName, string lastName, string major,int collegeYear);
    
};

Student::Student(int ID, string firstName, string lastName, string major,int collegeYear):Person(ID, firstName, lastName), major(major), collegeYear(collegeYear)
{
    Person(ID, firstName, lastName);
    this -> major       = major;
    this -> collegeYear = collegeYear;
}
Student needs to have a default constructor in order for line 35 in the first block to compile.

Why are you #including .cpp files? You should not be doing that.
Ah okay, I see and why shouldn't be including .cpp files?
I am new to C++ so I am still learning.
Topic archived. No new replies allowed.