Hello i'm trying to create a dynamic array of pointer to an object Student from Gradesclass but i can't figure out how to declare it in the header
that's the header:
class Grades
{
private:
Student** array;
int _numofStud;
public:
Grades();
Grades(const Grades& other);
~Grades();
and the grades constructor (i'm not sure it's right)
Grades::Grades()
{
this->array = new Student * [2];
for (int i = 0; i < 2; ++i)
{
this->array[i] = NULL;
}
this->array[0]= new Student("auto1", "12345");
this->array[1]= new Student("auto2", "67890");
this->_numofStud = 2;
}
The probleme is that before it even enter to the constructor, it creating me an array of Size 5 in Grades because i have 5 elements in the Student constructor
Student::Student(const char* name, char* id)
{
this->_numofgrade = 0;
this->setName(name);
this->setId(id);
this->_grades = NULL;
this->_average = 0;
}
And i can't add or modify this size
I want to put a default size of Grades to an array of 2 pointers to student object that i'll define as default then i'll have an other methods that add new Students by creating them and adding their pointers to the array Th problem is i can't change the size of array and i don't understand why
I hope i was clear in my explanation thanks for your help
that's the debuger and you can see when it's creating a new object Grades g1 it's creating an array of 5 instead off two fill the 2 first as i asked for and the 3 left i have no idea why they have been created and whats inside them

std::vector<Student>for yourarraymember!std::vector<Student>would seem more appropriate, and bring the added benefit of being far closer to RO3/5/0 compliant.std::vectoractually works? Do you know the size required inGrades()or do you want like aaddStudent(...)function that can be called many times?std::vectoryet so i'm not sure i can use it What i mean by "before enter the constructor" is that when i defineStudent ** arrayit's creating me automaticlay an array of size 5 and i can't understand how to modify this size The 5 element in student refere to every "this->"