c++ - Compile errors for double linked list code -


i have tried implement doubly linked list in c++. here code,

#include <iostream> using namespace std; //double linked list class link{     public:         long data;         link *next;      public:         link(long d) {             data=d;         }         void displaylink() {             cout<<data<<" "<<"\n";         } };  class firstl {     private:         link *first;         link *last;      public:         firstl() {             first=null;             last=null;         }     public:         bool empthy() {             return (first==null);         }      public:         void insertfirst(long dd) {             link *newlink=new link(dd);             if (empthy)                 last=newlink;             newlink->next=first;             first=newlink;         }      public :         void insertlast(long dd) {             link *newlink=new link(dd);             if (empthy)                  first=newlink;             else                 last->next=newlink;             last=newlink;         }       public :         long deletefirst() {             long temp=first->data;             if (first->next==null) //if 1 item                 last=null;//null<-last;             first=first->next; //first-->old next;             return temp;         }     public:         void displaylist() {             link *current=first;             while (current!=null) {                 current->displaylink();                 current=current->next;             }         } };  int main() {     firstl linked;     linked.insertfirst(22);     linked.insertfirst(44);     linked.insertfirst(66);     linked.insertlast(11);     linked.insertlast(33);     linked.insertlast(55);     linked.displaylist();     linked.deletefirst();     linked.deletefirst();     linked.displaylist();     return 0; } 

but here compile errors:

1>------ build started: project: linked)list, configuration: debug win32 ------ 1>  linked_list.cpp 1>c:\users\david\documents\visual studio 2010\projects\linked)list\linked_list.cpp(40): error c3867: 'firstl::empthy': function call missing argument list; use '&firstl::empthy' create pointer member 1>c:\users\david\documents\visual studio 2010\projects\linked)list\linked_list.cpp(51): error c3867: 'firstl::empthy': function call missing argument list; use '&firstl::empthy' create pointer member ========== build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 

how can fixed?

if (empthy) wrong, empthy function should if (empthy()).btw, method name should empty.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -