How can I initialize struct array with parameters in constructor? Now I have this code:
struct roundMatrix {
private:
int **matrix;
public:
roundMatrix(int teamsNumber) {
matrix = new int*[teamsNumber];
for(int i=0;i<teamsNumber;i++) {
matrix[i] = new int[teamsNumber];
}
}
int addPartners(int first, int second) {
if(matrix[first][second] == -1 && matrix[second][first] == -1) {
matrix[first][second] = 0;
matrix[second][first] = 0;
}
else {
return -1;
}
return 0;
}
};
...
Then I need to inintialize array of roundMatrix with parameter:
roundMatrix rounds[roundsNumber](teamsNumber);
And I got an error:
variable-sized object 'rounds' may not be initialized
One more question. How can I initialize vector with struct and constructor paramaters?