Quote:
Originally Posted by xpi0t0s View Post
Interesting. Did you get any warnings from the compiler, such as "condition is always true"?
No did not get warning, and will change the warning level.

Have another question using arrays. I have objects in HumanFighterShip, which are not objects of Spaceship, which are fire laser and fire missiles. The code (snippet) I have at present is as follows:
Code:
int main()
{
	
    HumanFighterShip* fighterHuman[3];
	
	fighterHuman[0] = new HumanFighterShip("Human Fightership Class 1", Vector3(5.0f, 6.0f, -3.0f), 
		Vector3(1.0f, 2.0f, 3.0f),100, 0, 1, 100);

	fighterHuman[1] = new HumanFighterShip("Human Fightership Class 2", Vector3(5.0f, 6.0f, -3.0f), 
		Vector3(1.0f, 2.0f, 3.0f),100, 0, 2, 110);

	fighterHuman[2] = new HumanFighterShip("Human Fightership Class 3", Vector3(5.0f, 6.0f, -3.0f), 
		Vector3(1.0f, 2.0f, 3.0f),100, 0, 3, 120);

	for(int i = 0; i < 3; ++i)
	{
    fighterHuman[i]->attacking();
	fighterHuman[i]->fireLaserGun();
    fighterHuman[i]->fireMissle();
	fighterHuman[i]->printStats();
	cout << endl;
	}
for(int i = 0; i < 3; ++i)
	{
	delete fighterHuman[i];
	}
Code:
//Spaceship.cpp
void HumanFighterShip::fireLaserGun()
{
	
	cout << "Firing " << mName << " laser guns." << endl;
}

void HumanFighterShip::fireMissle()
{
	
	if(mNumMissles > 0)
	{
		cout << "Firing " << mName << " missles." << endl;

		mNumMissles--;
	}
	else
		cout << "Out of missles." << endl;
}
Question is, if I change the following piece of code:
Code:
HumanFighterShip* fighterHuman[3];

to 

Spaceship* fighterHuman[3];
it tells me that the 2 objects mentioned are not members of Spaceship. I might be barking up the wrong tree, but should you not use a pointer to the base class, or would that be wrong? If it is and if you dont mind, could you explain why