can anyone help me to solve this problem ?
i cannot excute this program.
-----------------------------------------------------------
#include<iostream>
#include<string>
using namespace std;
class linklist
{
private:
struct node{
struct student{
string name;
int id;
string prog;
double cgpa;
}st;
node *link;
}*head;
public:
void linklist_1();
void linklist_2();
void insFirstNode (string name, int id, string prog, double cgpa);
void printAllList();
};
void linklist::linklist_1()
{
head = NULL;
}
void linklist::linklist_2()
{
node *p;
if (head == NULL)
return ;
while (head !=NULL)
{
p = head -> link ;
delete head;
head = p;
}
}
void linklist::printAllList()
{
node * cur;
cur = head;
cout<<"( ";
while(cur !=NULL)
{
cout<< cur->st.name;
cout<< cur->st.id;
cout<< cur->st.prog;
cout<< cur->st.cgpa;
cur = cur->link;
if(cur !=NULL)
cout<<",";
}
cout<<" }"<<endl;
}
void linklist::insFirstNode(string name, int id,string prog, double cgpa)
{
node * newNode;
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)
{
head = newNode;
}
else
{
newNode->link = head -> link;
head ->link = newNode;
}
}
int main()
{
linklist L;
L.insFirstNode("John",687,"BM",3.0);
L.insFirstNode("MAX",187,"gM",3.0);
L.printAllList();
return 0;
system("pause");
}