【发布时间】:2017-11-03 09:40:34
【问题描述】:
我正在用 C++ 编写这个链表程序
当我测试程序时,我得到了错误
linkedlist.cpp:5:24:错误:隐式声明的“constexpr LinkedList::LinkedList()”的定义 链表::链表(){
这是代码
linkedlist.h 文件:
#include "node.h"
using namespace std;
class LinkedList {
Node * head = nullptr;
int length = 0;
public:
void add( int );
bool remove( int );
int find( int );
int count( int );
int at( int );
int len();
};
linkedlist.cpp 文件:
#include "linkedlist.h"
#include <iostream>
using namespace std;
LinkedList::LinkedList(){
length = 0;
head = NULL;
}
/*and all the methods below*/
请帮忙。
【问题讨论】:
-
如果您所做的只是成员的初始化,则不需要构造函数 - 您已经在标题中完成了。
标签: c++ compiler-errors