I got this error while coding a simple function. This is my function specification.
string studentName;
string courseTaken[3];
void setStudent(string, string[]);
void Student::setStudent(string n, string a[])
{
studentName= n;
courseTaken = a;
}
This is the error I have gotten:
incompatible types in assignment of string* to string [3] on this line courseTaken = a;
In my code, I never declared any pointer or char.
I don't quite understand what is going wrong here.
std::arrayorstd::vector. This is not C.void Student::setStudent(string n, string *a). By "this is not C", @user202729 means that you should use C++ containers instead of C arrays, which has some unintuitive things about it especially when you try to pass it to a function. He/she is likely referring to the common bad practice of teaching C stuff before C++ stuff.