I'm trying to workout a problem in C++ regarding inheritance and wondering how to go about doing it correctly.
I have 3 classes set up: - Enemy (which has member data: int Damage, int Health and int Level) - Wolf - Bear
The way my inheritance is set up is: Wolf is-a Enemy and Bear is-a Enemy. In other words, both Wolf and Bear inherit from Enemy.
I want to set up my program so that when I create a new Enemy like so:
Enemy anEnemy;
Then in Enemy::Enemy() constructor it will randomly decide whether that enemy is a Wolf or a Bear.
How would one approach this problem? I know I'd have to generate a random number in the Enemy::Enemy() constructor and based on the result of the random number it would turn the enemy into either a bear or wolf. But I just can't wrap my head around how to "turn it" (the enemy) into a wolf or a bear.
Any help would be really appreciate. Thanks!