在一个声明中出现多种类型的问题

时间:2015-10-13 03:43:59

标签: c++ class unix

当我尝试编译时,我得到错误:

#ifndef EDITORLIST_H
#define EDITORLIST_H

#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;

class EditorList

class Node
{
    friend class EditorList;
  private:
    Node *nextNode;
    int lineNum;
    string lineText;

  public:
    Node(void)
    : nextNode(NULL)
    {}

    Node(int val)
    : lineNum(val), nextNode(NULL)
    {}

    Node(int val,  Node* next)
    : lineNum(val), nextNode(next)
    {}

    int getLine(void)
    {return lineNum;}

    string getText(void)
    {return lineText;}

    Node* getNext(void)
    {return nextNode;}
};

class EditorList
{
  private:
    Node *head;
    Node *tail;

  public:
    EditorList(void);
    EditorList(int val);
    //-EditorList(void);

    void insertHead(int val);
    void insertInside(Node* inptr, int val);
    void insertEnd (int);
    Node* getNode(int pos);
    void deleteLine (int);
    void printText ();
    void displayMenu ();
    void saveQuit (); 
};

#endif  /* EDITORLIST_H */

错误在于此:

addSubView

我真的不确定是什么导致这个,因为我唯一的另一次看到这个错误我在类定义之后忘记了半冒号,但这似乎不是这里的情况。任何帮助表示赞赏。

2 个答案:

答案 0 :(得分:1)

在EditorList前向声明后缺少半冒号

答案 1 :(得分:1)

不是100%肯定,但我相信你需要一个;在课前宣言之后。

using namespace std;

class EditorList

class Node

应该是

using namespace std;

class EditorList;

class Node