@monkey:
thx for the hint. so far there was never need for me to redefine the copy constructor or the assignment operator. but i will try...
btw: i always declare ALL access functions as private (except for bools; actually i don't use funcs for bools und thus make the boolean attributes public), but that can't be the point here (though i admit that it might be better to also declare the bools private)
@auria:
its quite simple. i run through an array of spinCtrls, and if their value is greater than zero a new object is created (i'm at work now, but it must go like this):
Code: Select all
void AssignArmy() {
Stone* tmpStone=new Stone*[stoneCount];
int aux=0;
for (int i=0; i<stoneCount; i++) {
if (spins[i]->GetValue()>0) {
for (int j=0; j<spins[i]->GetValue(); j++) {
//Stone constructor takes values for team, value and position
Stone* tS=new Stone(game->GetTeamOn(), i, -99);
tmpStone[i]=tS;
//cleanup
delete tS;
tS=NULL;
}//for
}//if
//assign to the configClass
if (game->GetTeamOn()==1)
game->GetMyPlayer->SelectArmy(tmpStone, stoneCount);
else
game->GetOpponent()->selectArmy(tmpStone, stoneCount);
//tmpStone can now be deleted
delete tmpStone;
tmpStone=NULL;
}//end of function; dialog ends modal immediately after this
as for the SelectArmy(), it only copies the submitted array:
Code: Select all
//in class Player:
void Player::SelectArmy(Stone* sStone[], int sCount) {
army=sStone;
armyStrength=sCount;
}//SelectArmy()
there must be a more elegant way to determine the size of the array, but i have difficulties getting it (since sizeof() always returns the size of ONE pointer to object of this class, no matter wether it is called on an array)