0
I have an issue adding nodes to a linked list dynamically. I have a header and source file for mode class and 1 for list class.
Class Enemy( private: ... Enemy* nextE(next); public: Enemy(int eHP, string eName, int eExp, int eDamage) ... addEnemy(int eHP, string eName, int eExp, int eDamage) Linked List Header File Enemy newEnemy = new Enemy(eHP, eName, eExp, eDamage) if(tailE = NULL) headE = tailE = newEnemy <- Problem Code compiles no problem without this function. The compiler gives an error where it says "a value of type "Enemy*" cannot be assigned to an entity of type "Enemy" I don't have enough space to write more detail
2 odpowiedzi
+ 4
You forgot to specify that newEnemy is a pointer:
Enemy* newEnemy = new Enemy(eHP, eName,eExp,eDamage)
0
I did that but it's still giving me the same error.