0

私はVS2008を使用しており、学校のプロジェクトのためにMFCで開発しています。コード構造はbouml 4によって生成され、それを使用したいときに問題が発生しました。エラー C2061: syntax error : identifier 'Node' で数時間スタックしており、解決方法がわかりません。ここでコンパイルエラーが発生します。

Link.h

#pragma once

#include "model/MapIndicator.h"
#include "model/Highlightable.h"

class Node;
struct COORDINATE_AREA;

class Link : public MapIndicator {
public:
    explicit Link();
    Link(Node * node1, Node * node2); // Error on this line
protected:
    Link(const Link & source);
public:
    virtual ~Link(); 
...

Node.h

#pragma once

#include "model/MapIndicator.h"
#include <vector>
using std::vector;
#include "model/COORDINATE.h"
#include "model/Highlightable.h"

class Site;
struct COORDINATE_AREA;

//Node will be repaint several times in one refresh.
class Node : public MapIndicator {
public:
    explicit Node();

protected:
    Node(const Node & source);

public:
    virtual ~Node();

private:
    Node & operator=(const Node & source);

public:
    //This function will only add other node in its adjacent node list.
    //Note: Duplicate adding will have no effect.
    void addAdjNode(Node * otherNode);

    vector<Node *>::size_type getAdjNodeCount();

    //Remove specified node from its adjacent node list.
    //Return true if succeeds, Return false if that node doesn't exist in list.
    bool removeAdjNode(const Node * adjNode);

    //Add site which use this instance as reference node to referenced site list.
    void addRefSite(Site * refSite);

    vector<Site *>::size_type getRefSiteCount();

    //Remove specified site from its referenced site list.
    //Return true if succeeds, Return false if that site doesn't exist in list.
    bool removeRefSite(const Site * refSite);

    inline COORDINATE getNodeCoordinate() const;

    void setNodeCoordinate(COORDINATE value);

    //Draw itself according to the size and the coordinate of display area and its own coordinate.
    virtual void DrawInRect(const RECT & viewDispRect, const COORDINATE_AREA & mapDispCoordinate, CDC * pDC);

    //Return true if indicator have something to show in the coordinate area specified in parameter, otherwise return false.
    virtual bool VisibleInArea(const COORDINATE_AREA & mapDispCoordinate);

    //Return distance in double between screen position of this indicator and the screen point.
    virtual double DistanceInPixel(const RECT & viewDispRect, const COORDINATE_AREA & mapDispCoordinate, const CPoint & point);

    //Set display state directly.
    virtual void SetDispState(DispState dispState);

    //If hover is true and current state is normal, set state to hover.
    //If hover is false and current state is hover, set state to normal.
    //Otherwise no effect.
    virtual void SetHover(bool hover);

private:
    vector<Node *> adjNodes;

    vector<Site *> referencedSites;

    COORDINATE nodeCoordinate;

};
inline COORDINATE Node::getNodeCoordinate() const {
  return nodeCoordinate;
}

MapIndicator.h

#pragma once

#include "model/MapObject.h"
#include "model/Drawable.h"
#include "model/Locatable.h"
#include "model/Highlightable.h"

struct COORDINATE_AREA;

//This enum specifies different kinds of indicators available to identify.
enum IndicatorType {
  Road,
  Link,
  Node,
  Site

};
//MapIndicator is a artifact on map given varies kinds of hint to user.
class MapIndicator : public MapObject, public Drawable, public Locatable, public Highlightable {
public:
    explicit MapIndicator(IndicatorType indicatorType);
...

また、MapObject、Drawable、Locatable、Highlightable のヘッダーには include ステートメントはなく、#pragma once のみです。

そして主要なコンパイル出力:

1>Link.cpp
1>c:\project\model\link.h(12) : error C2061: syntax error : identifier 'Node'
1>c:\project\model\link.h(12) : error C2535: 'Link::Link(void)' : member function already defined or declared
1>        c:\project\model\link.h(11) : see declaration of 'Link::Link'

実際、このエラーは私のプロジェクトのいたるところで発生しますが、なぜですか? 私が使用するのはポインターであり、再帰的なインクルードはありません。

4

1 に答える 1