can anyone show me how to convert this linkList statement into Array ?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class linklist
{
private:
struct node{
struct student{ // node->info
string name;
int id;
string prog;
double cgpa;
}st;
node *link;
}*head;
public:
void insFirstNode (string name, int id, string prog, double cgpa);
};
void linklist::insFirstNode(string name, int id,string prog, double cgpa)
{
node * newNode,*p;
newNode = new node;
newNode -> st.name = name;
newNode -> st.id = id;
newNode -> st.prog = prog;
newNode -> st.cgpa = cgpa;
newNode -> link = NULL;
if (head == NULL) //insert first node
head = newNode;
else
{
p = head;
while ((p->link !=NULL)) // link to the next node
p = p->link;
p->link = newNode; //insert to the next node
}
}