Can someone explain what my prof wants? I am really bad at pointers and have no idea how to use them.

Here is my constructor for SeatSelection class we used in Assignment 1.

SeatSelection::SeatSelection(int fRow, int nRows) {

firstRow = fRow;

numRows = nRows;

seats = new int * [numRows];

for(int i=0 ; i<numRows ; i++) {

seats[i] = new int [NUMSEATS];

for(int k=0 ; k<NUMSEATS ; k++)

seats[i][k] = 0;

}

}

Let us enhance it so that each row can have varying # of seats. We will pass a pointer seatsInRows that contains # of seats in each row. Now, enhance the code for constructor to accommodate this change.

SeatSelection::SeatSelection(int fRow, int nRows, int *seatsInRows) {

...

}

Here is my constructor for SeatSelection class we used in Assignment 1.

SeatSelection::SeatSelection(int fRow, int nRows) {

firstRow = fRow;

numRows = nRows;

seats = new int * [numRows];

for(int i=0 ; i<numRows ; i++) {

seats[i] = new int [NUMSEATS];

for(int k=0 ; k<NUMSEATS ; k++)

seats[i][k] = 0;

}

}

Let us enhance it so that each row can have varying # of seats. We will pass a pointer seatsInRows that contains # of seats in each row. Now, enhance the code for constructor to accommodate this change.

SeatSelection::SeatSelection(int fRow, int nRows, int *seatsInRows) {

...

}

Topic archived. No new replies allowed.