[Solved] Constructor doesn’t accept char *


To pass literal string to a function, it must have a parameter of type char const *, not char *. So your constructor should have this prototype:

Etudiant(char const * c, unsigned int, Date &);

Saying the above, you also do not allocate enough memory to copy a string in your constructor. This line:

this->name = new char();

should likely be:

this->name = new char[strlen(c) + 1];

so you have enough memory for this copy operation:

strcpy(this->name, c);

11

solved Constructor doesn’t accept char *