For a project I am involved in, I have a 2D array representing a map. I want to create a class representing a zone on the map. There will be numerous zones on my map that will be different sizes, i.e. varying numbers of map array elements in each zone. What I have in mind is as follows:
Is what I have in mind possible? I am getting errors and I think it is to do with the non-constant nature of num_of_squares.Code:class zone { private: int num_of_squares; int square_coordinates[num_of_squares][2]; //array giving map x and y coordinate for each square public: void set_squares(int a); void set_coordinates(int i, int pos_x, int pos_y); }zone1; void zone::set_squares(int a) { num_of_squares = a; } void zone::set_coordinates(int i, int pos_x, int pos_y) { square_coordinates[i][0] = pos_x; square_coordinates[i][1] = pos_y; } //here I call zone1.set_squares and zone1.set_coordinates to initialise all class variables
Any help would be much appreciated
Thanks



LinkBack URL
About LinkBacks


