Can someone please check and see if im on the right track with this linked list? If i am completely wrong, can you please put me on the right track? :-D
PHP Code:
#include <iostream>
using namespace std;
typedef struct _Node {
char *name;
int age;
struct _Node *next;
} NODE;
NODE *root;
class LinkedList
{
public:
LinkedList();
~LinkedList();
bool AddNode(char *tName, int tAge);
bool DelNodeName(char *tName);
bool DelNodeAge(int tAge);
};
bool LinkedList::AddNode(char *tName, int tAge)
{
NODE *temp;
while(temp->next)
{
temp = temp->next;
}
NODE *NewNode;
NewNode = new NODE;
NewNode = temp->next;
temp->next = NewNode;
NewNode->name = tName;
NewNode->age = tAge;
return true;
}
bool LinkedList::DelNodeAge(int tAge)
{
NODE *temp;
temp = root;
while(temp->next->age != tAge)
{
temp = temp->next;
}
temp->next = temp->next->next;
delete temp->next;
return true;
}
int main(int argc, char *argv[])
{
return 0;
}