I am trying to learn C ++ myself and am trying to do this. I have a structure whose member is an array of other structures. I have a question about alternative notation.
The structures that I defined
struct employeeRecordT {
string name;
string title;
string ssnum;
double salary;
int withholding;
};
struct payrollT {
int num;
employeeRecordT *array;
} payroll;
I allocate memory for payroll using the following construction
payroll.array = new employeeRecordT[payroll.num];
where payroll.num indicates the number of elements in the array. I can access the element name employeeRecordT using array notation, for example.
payroll.array[i].title
I wanted to know how to access this using pointer notation, I tried
payroll.(array+i)->name = "Vikas";
and I get the following error message from g ++
toy.cc30: 13: error: unqualified identifier expected before '(' token toy.cc30: 14: error: 'array' was not declared in this area
, ? , , .
.
,