C++ LinkedList.cpp:6:8:错误:â;链接列表â;不命名类型
我刚刚开始编写类的.cpp文件,但我的编译器似乎无法识别默认构造函数或类。 这就是我所拥有的C++ LinkedList.cpp:6:8:错误:â;链接列表â;不命名类型,c++,C++,我刚刚开始编写类的.cpp文件,但我的编译器似乎无法识别默认构造函数或类。 这就是我所拥有的 //LinkedList.h #ifdef Linked_List #define Linked_List typedef int Node::element; #include "Node.h" #include <iostream> class LinkedList{ public:
//LinkedList.h
#ifdef Linked_List
#define Linked_List
typedef int Node::element;
#include "Node.h"
#include <iostream>
class LinkedList{
public:
//Default
LinkedList();
//Checks if empty
bool empty();
//Inserts [Element] in front;
void insertFront(Element e)
//Prints out all [Element]s in LinkedList
friend std::ostream& operator<<(std::ostream& os, const LinkedList x);
//Removes [Element] from the front of the list
Element removeFront();
//Removes [ELement] from the back of the list
Element removeBack();
//Inserts an [Element] at position 'i'
void insertAt(Element e, int i);
//Removes an [Element] at position 'i'
Element removeAt(int i);
//Finds the [Element] 'e' and returns its position
int find(Element e);
private:
Node *first;
Node *last;
};
#endif
我已经看了一个小时了,还是想不出来。如果你们能帮我的话,我会非常感激的。你们的防守是错误的。你需要
#ifndef Linked_List
而不是
#ifdef Linked_List
其结果是,前置处理器没有正确地将标题包含在
LinkedList.cpp
中。我不确定typedef
在那里做了什么。那应该在节点内
。你是认真的吗。。。非常感谢。我觉得自己像个白痴…@user3399119总是这样。很高兴这有帮助。
#ifdef Linked_List