hussamo -3 Newbie Poster

// i need a linked list that can do those functions
//-------->>> insert , delete ,search ,check if empty ,print <<<-----------

// plzzzzzzzzzz i can't inderstanund
//i did understand the insert functoin but the other not :'(

#include <iostream>
using namespace std;


class link
{
   public:
   struct employee
  {
   int x;
   employee *next;
  };
     link(){cout<<"Link's constructor.."<<endl;}
     ~link(){cout<<"Link's destructor"<<endl;}
     void insert()
   {
	   
    employee *first=NULL;
first=new employee;
employee *temp=NULL;
temp=new employee;
employee *temp2;
temp2= new employee;

if(first==NULL)
{
cin>>first->x;
temp=first;
first=temp;
     }
     else
      {
        cout<<"Enter a number..";
        cin>>first->x;
        temp2=first;
		first=temp2;
		first->next;
      }
    }
	 void print()
	 {
		 employee *temp2;
		employee *first;
		while(first!=NULL)                     // how to fix this function so that 
												//it can do pritn for the linked list
		{
		cout<<first->x<<endl;
		first=temp2->next;
		}
	 }
	 void empty()
	 {
		 //plz tell me how to write this function
	 };
	 void search()
	 {
	 //this one to
	 };
	 void del()
	 {
		 //this one to
	 };
};

int main()
{
 link x;
 int y;
 do
 {
  cout<<endl;
  cout<<"Select one of the following"<<endl;
  cout<<"1- Insert "<<endl;
  cout<<"3- print "<<endl;
  cout<<"3- exit "<<endl;
  cin>>y;
  switch(y)
   {
    case 1:
    x.insert();
    break;
	case 2:
		x.print();
		break;
    case 3:
		x.search();
    break;
    case 4:
		x.del();
    break;
	 case 5:
		 x.empty();
    break;
	 case 6:
    break;
  }


 }while(y!=6);
 return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.