I'm trying to write a clone of Galaga using the allegro library and have been using classes. I have a class called enemy and I'm wondering why this isn't a valid call to the destructor
Code:
class Enemy {
int health;
public:
int x_position;
int y_position;
bool collision;
BITMAP *image;
//constructor
Enemy(int x, int y,int h = 1){
x_position = x;
y_position = y;
health = h;
bool collision=false;
image = load_bitmap("enemyShip.bmp", NULL);
}
//destructor
~Enemy(){destroy_bitmap(image);}
//class functions
int get_health(){return health;}
void movement(int&x,int&y);
};
then I have the function definiton for movement here
Code:
void Enemy::movement(int &x, int &y)
{
while(collision==false)
{
//try to add support for sin movement across screen
}
if (collision==true){~Enemy();}
}
is it not valid to call the destructor inside a class function?
this is the compiling error
error C2512: 'Enemy::Enemy' : no appropriate default constructor available
I'm figuring this means that it's thinking I'm trying to call a constructor? If so, am I mistaken that the ~Enemy() call isn't a destructor, I was under the impression that it was.
Sorry if this is a stupid question.
Thanks for the Help,
mjhamrick