Complete Beginner in C++.
This is a member initialization list:
Student.cpp
Student::Student(int studentID ,char studentName[40]) : id(studentID), name(studentName){};
Student.h
class Student{
protected:
char name[40];
int id;
}
My problem is that name is of type char[40], so, name(studentName) displays an error of:
a value of type "char *" cannot be used to initialize an entity of type "char [40]"
How can I initialize name array, to studentName array in the member initializer list?
I don't want to use string, and I have tried strcpy and didn't work
std::arrayinstead or even betterstd::stringnamearray. I am trying to grasp thestd::arraystd::stringstores bytes. Whatever is going wrong with reading the file would be the same with character arrays.