I am working on A Star algorithm and I have run into problem I am not sure how to realize. I am loading map from file of chars, where '*' represents walkable node and ' ' represents non-walkable. I load the map into 2dim char array, dynamically allocated. The loading and parsing works just fine, but I need to return my own object - Map, which is build of 2dim array of Nodes (my own object).
Since I need to dynamically create the 2dim array of Nodes, it would be awesome to intialize them already too, since I know all the information for initialization, but I don't know how. I need to pass them x, y and walkable flag - is this possible during creating the array, or do I really have to create the array first and then loop through it and make some method "setNode(...)" to initialize the nodes again?
If your Nodes are structs then you will need a loop to initialize values; if they're class objects then your default constructor should explicitly set default values, and you should consider an explicit constructor taking (int,int,bool) arguments or whatever you need.