How to access struct fields in array
Dear C++ experts out there,
I am trying to access to array of struct data fields in a class.
but compiler keep display error when access to struct fields.
How class methods can access to the fields of a struct (array of struct) ?
Code:
struct StudentType
{
int age;
char gender;
};
class StudentRecordHandler
{
public:
StudentRecordHandler();
void SetAge(int a); //compile error
int GetAge(); //compile error
void SetGender(char gen); //error
char GetGender(); // also error
void SetRecordNumber(int RecNum); // OK
int GetRecordNumber(); // OK
//........
private:
StudentType stud[20];
//additional data member for StudentRecordHandler
int RecordNum,
string Registrar;
}
Thank you very much for your help