Repair error please

#include<iostream>
using namespace std;
struct Node
{
int info;
Node *link;
};
class LinkedList
{
Node *first,*last;
int counter;
public:
LinkedList();
bool isFull();
bool isEmpty();
void insertAtFirst(int );
void insertAtLast(int );
void print();
};


void LinkedList::print()
{
Node *c;
c=first;
while (c!=0)
{
cout<<c->info<<" ";
c=c->link;
}
cout<<endl;

// cout<<"the list is empty"<<endl;
// cout<<endl;
}




void LinkedList::insertAtFirst(int elem)
{
Node *n;
n=new Node;
n->info=elem;

if(first == 0)
{
first=n;
last=n;
n->link=0;
}
else
{
n->link=first;
first=n;
}
counter++;
}


void insertAtLast(int elem)
{
Node *n;
n=new Node;
n->info=elem;
if(first==0)
{
last=n;
n->link=0;
}
else
{
last->link=n;
//n->link=0;
last=n;
}
counter++;
}

bool LinkedList::isEmpty()
{
return(first==0);
}
bool LinkedList::isFull()
{
return false;
}
LinkedList::LinkedList()
{
first=0;
last=0;
counter=0;
}

void main()
{
LinkedList obj;
obj.insertAtFirst(9);
obj.insertAtFirst(9);
obj.insertAtFirst(3);
obj.print();
}



Repair error
Last edited on
void LinkedList::insertAtLast(int elem)
Thank you very much
Topic archived. No new replies allowed.