I create a pointer-to-pointer of a class object and when I try to create a new object using the pointers it seg-faults. Why does this happen?
struct Level
{
int SoldierCount;
Soldier **soldier;
int taskCount;
int *taskPercentage;
int *taskBitmapX;
int *taskBitmapY;
}level;
void createMap()
{
//Input and Declartion of various variabls goes here
level.soldier = new Soldier* [level.SoldierCount];
//Seg Faults Here
level.Soldier[i] = new Soldier(initX, initY, initDirection, steps);
}
The Soldier Class Constructor:
Soldier(int, int, int, int);