0

Can someone please help me with this error? It shows an "invalid types 'char[int]' for array subscript" error.

// sets the student's gender with the char passed in void Student::setGender (char Gender) { for(int c = 0; c < 1; c++){ // we use t < 1 because Gender holds a one-character value gender_[c] = Gender[c]; } } // returns the student's gender string Student::getGender (void) { return gender_; }

3rd Dec 2020, 4:15 AM
Floyd
Floyd - avatar
2 Respostas
+ 8
Hii Floyd Ack So like in your gender[c], don’t do that! Since you’re passing in a char already, you don’t have to do char[0] Just do gender = Gender or something along those lines.. That might help!👍
3rd Dec 2020, 4:32 AM
Piyush
Piyush - avatar
+ 2
Thank you very much!
3rd Dec 2020, 4:41 AM
Floyd
Floyd - avatar