So, is this doing it right?
Code:
#include <iostream>usingnamespacestd;
struct EnemySpaceShip {
int weaponPower;
EnemySpaceShip* p_next_enemy;
};
EnemySpaceShip* addNewEnemyToList (EnemySpaceShip* p_list) {
EnemySpaceShip* p_ship = newEnemySpaceShip;
p_ship->weaponPower = 20;
p_ship->p_next_enemy = p_list;
return p_ship;
}
int main () {
EnemySpaceShip* p_enemies = NULL;
addNewEnemyToList(p_enemies);
EnemySpaceShip* p_newEnemy = NULL;
p_newEnemy = addNewEnemyToList(p_newEnemy);
cout << p_newEnemy->weaponPower;
}
I think that this is supposed to set a head and initialize it to NULL, then add another ship to the list and print it's weaponPower.