简体   繁体   English

错误:''尚未声明

[英]error: '' has not been declared

I'm trying to implement a linked list but get an error when compiling: 我正在尝试实现链接列表但在编译时遇到错误:

intSLLst.cpp:38: error: 'intSLList' has not been declared intSLLst.cpp:38:错误:'intSLList'尚未声明

intSLList looks like it's been declared to me though so I'm really confused. intSLList看起来像是向我宣布的,所以我真的很困惑。

intSLLst.cpp intSLLst.cpp

#include <iostream>
#include "intSLLst.h"


int intSLList::deleteFromHead(){
}

int main(){

}

intSLLst.h intSLLst.h

#ifndef INT_LINKED_LIST
#define INT_LINKED_LIST
#include <cstddef>

class IntSLLNode{
  int info;
  IntSLLNode *next;

  IntSLLNode(int el, IntSLLNode *ptr = NULL){
    info = el; next = ptr;
  }

};

class IntSLList{
 public:
  IntSLList(){
    head = tail = NULL;
  }

  ~IntSLList();

  int isEmpty();
  bool isInList(int) const;

  void addToHead(int);
  void addToTail(int);

  int deleteFromHead();
  int deleteFromTail();
  void deleteNode(int);

 private:
  IntSLLNode *head, *tail;

};

#endif

You're using a lower case i 你使用的是小写字母i

int intSLList::deleteFromHead(){
}

should be 应该

int IntSLList::deleteFromHead(){
}

Names in c++ are always case sensitive. c ++中的名称始终区分大小写。

intSLList isn't the same as IntSLList . intSLListIntSLList This isn't Pascal. 这不是Pascal。 C++ is case sensitive. C ++区分大小写。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM