【问题标题】:'StringLinkedList' was not declared in this scope [closed]未在此范围内声明“StringLinkedList”[关闭]
【发布时间】:2016-02-04 15:36:59
【问题描述】:

我收到了这个错误

'StringLinkedList' 未在此范围内声明

这是我的代码

我不知道为什么会出现这个错误

StringNode.h [头文件]

#ifndef StringNode_H
#define StringNode_H
#include<iostream>
#include<string>
using namespace std;
class StringNode{
private:
    string elem;
    StringNode* next;

friend class StringLinkedList;  
};

#endif

StringLinkedList.h [头文件]

#include "StringNode.h"
#ifndef StringLinkedList_H
#define StringLinkedList_H

class StringLinkedList{
private:
    StringNode* head;
public:

StringLinkedList();
~StringLinkedList();
bool empty() const;
const string& front() const;
void addFront(const string& e);
void removeFront();
void displaylist();
};

#endif

StringLinkedList.cpp

#include "StringLinkedList.H"
#include<iostream>
using namespace std;

StringLinkedList::StringLinkedList(){
this->head = NULL;
}

mainclass.cpp

#include<iostream>
using namespace std;

int main()
{
StringLinkedList a;
return 0;
}

【问题讨论】:

  • 你在mainclass.cpp中忘记了#include "StringLinkedList.H"

标签: c++ c++11 linked-list singly-linked-list


【解决方案1】:

您忘记在模块mainclass.cpp 中包含标题

【讨论】:

  • 天哪!谢谢 !!我没看到
猜你喜欢
  • 2013-02-17
  • 2021-12-16
  • 2013-10-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多