For 1d array you can initialize objects like this:
Code:
class SearchArea
{
public:
int Fscore; //total value to asses select node or not
int Gscore; //movement cost
int Hscore; //heurestic
int Walkstate; //is it valid terrain
int Liststate; //is it available? on open or closed list
int STnode; //is it a / the search start point
int TGnode; //is it a / the search target point
int Xcord; // map node X (across) location
int Ycord; // map node Y (down) location
SearchArea(int a, int b, ....) {
Fscore = a;
Gscore = b;
...
}
};
int main()
{
SearchArea temp[2] = {SearchArea(1, 3, 1, ...), SearchArea(2, 3, 4, ...)};
...
}
If you want to initialize everything to 0 you could do this:
Code:
class SearchArea
{
public:
int Fscore; //total value to asses select node or not
int Gscore; //movement cost
int Hscore; //heurestic
int Walkstate; //is it valid terrain
int Liststate; //is it available? on open or closed list
int STnode; //is it a / the search start point
int TGnode; //is it a / the search target point
int Xcord; // map node X (across) location
int Ycord; // map node Y (down) location
SearchArea(i) {
Fscore = 0;
Gscore = 0;
...
}
};
int main()
{
SearchArea s[10][10];
}
Yeah, you could easilty overflow the stack with a big number. You can dynamically allocate the objects instead with the new operator.
Also, consider vector<> instead of an array, since it makes things easier