This is the code that I'm using to setName
void Student::setName(const char * const name) {
this->name = new char[strlen(name)+1];
strcpy(this->name,name);
}
and this is my deletor
Student::~Student() {
perm = 0;
delete[] this->name;
}
but when I run valgrind, I get
13 bytes in 1 blocks are definitely lost in loss record 1 of 1
==1786== at 0x4C2FBC3: operator new[](unsigned long)
(vg_replace_malloc.c:433)
==1786== by 0x402167: Student::setName(char const*)
(student.cpp:25)
==1786== by 0x4020F1: Student::Student(char const*, int)
(student.cpp:7)
==1786== by 0x401A73: main (testStudentRoll01.cpp:11)