DrEvil
FCRI Associate!
- Reaction score
- 111
So I created a linked list class for 'Enemy' class, and while this works, I would like to expand the 'LinkedList' class to be able to work for any type of variable:
EnemyList<int> ?
Like I have seen this before on thing such as vector<int>; vector<Enemy>.
How do I create something like this, which doesn't have a set type.
Like I know I'd have to rethink the delete<type> method but I'l take it one step at a time...
(Also any ideas on how the deleteElement function could work would also be appreciated, as the current method is comparing an index: enemy.index==(tempNode).index, then removing)
Code:
class EnemyList{
private:
class Node{
public:
Node* _next;
Enemy _enemy; //<--- Change Enemy to whatever type
//int id;
};
public:
Node* _head;
EnemyList(){_head=NULL;};
void addEnemy(Enemy enemy); //<--- Change Enemy to whatever type
void deleteEnemy(Enemy enemy); //<--- Change Enemy to whatever type
};
Like I have seen this before on thing such as vector<int>; vector<Enemy>.
How do I create something like this, which doesn't have a set type.
Like I know I'd have to rethink the delete<type> method but I'l take it one step at a time...
(Also any ideas on how the deleteElement function could work would also be appreciated, as the current method is comparing an index: enemy.index==(tempNode).index, then removing)