if ( (shipArray[h][w]->getBelongs() == 2) && (shipArray[h][w]->isAlive()))
{
cout<<"Hit!\n";
}
need help for this, how do I declare my ship isAlive == false once hit? isAlive is true so how do I change it to false once hit? Sorry if my english is bad, but help will be much appreaciated.. Thank you =)
We don't know the type of shipArray (although by looking at the name it's probably ship) and how its defined, therefore, we might have some great difficulties telling you.
If those are all the functions and alive is a private or protected member... then the easiest way without changing your class is to construct a new dead ship with all the same values as the ship you want dead (except for alive) using your second constructor and replacing the ship that you want dead with your new ship.
The right way to do it, however, is to add another function that sets alive to false.
If alive is public, just use shipArray[h][w]->alive = false;.
here is my project, i dunno wat to do now T.T i juz need to be able to make dead my ships then keep looping the game till one player has no more ships.. http://www.mediafire.com/?wy2mywnqzng