编译双链表代码的错误

dat*_*ili 1 c++

我试图在C++中实现双向链表.这是代码,

#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 only one 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;
}
Run Code Online (Sandbox Code Playgroud)

但这里是编译错误:

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' to create a pointer to 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' to create a pointer to member
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Run Code Online (Sandbox Code Playgroud)

怎么解决这个问题?

ken*_*ytm 8

empthy是一种方法,因此需要结束()调用它.

void insertfirst(long dd){

    Link *newlink=new Link(dd);
    if (empthy())      // <-----
        last=newlink;
    ...
Run Code Online (Sandbox Code Playgroud)