libin7099901
有关链表

[mw_shl_code=cpp,true]class Link{

public:

int data;

Link *next;

Link(const int info, Link *nextValue = NULL){

data = info;

next = nextValue;

}

Link(Link *nextValue){

next = nextValue;

}

};

class linkList:public Link{

private:

Link *head, *tail;

Link *setPos(const int p);

public:

linkList(int s);

~linkList();

bool isEmpty();

bool sort();

bool uniq();

void clear();

int length();

bool append(const int value);

bool insert(const int p, const int value);

bool _delete(const int p);

bool getValue(const int p, int& value);

bool getPos(int &p, const int value);

};

linkList::linkList(int s){

head = tail = new Link(s);

}[/mw_shl_code]

我很好奇为什么最后那个函数会提示我"error C2512: “Link”: 没有合适的默认构造函数可用"

呢....他是哪用到了构造函数啊- -...

黑心の布偶兔ˇ
写链表来着
展开Biu

私用struct写链表来着。。

[查看全文]
lometsj
为什么一个链表还要写
展开Biu

为什么一个链表还要写class,用数组下标做伪链表就好了啊,速度跟机构体的正常链表差不到好多

[查看全文]
libin7099901
我大概有点想法
展开Biu

好吧..我大概有点想法...就是继承的时候..要调用Link的构造函数.....所以在linkList的构造函数里要提供Link的构造函数调用...但是为毛要继承Link啊- -....书上是这么写的.....聚合的关系不就可以么???

然后 - -..如果要用到继承的话..我该怎么调用Link的构造函数啊..它构造啥了啊= =..

[查看全文]