Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        3年前关闭。
                                                                                            
                
        
我收到此错误

未在此范围内声明“ 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;
}


主类

#include<iostream>
using namespace std;

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

最佳答案

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

关于c++ - 未在此范围内声明“StringLinkedList”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35205165/

10-10 11:17