私はしばらくの間、構文エラーC2061を探していましたが、これはヘッダーファイルの循環依存性によって引き起こされることがよくあることがわかりました。しかし、私は私のファイルでこれを解決しておくべきだと私はまだ問題を持っていると思う。C++カスタムヘッダーファイル - 構文エラーC2061:識別子
Arc.h
#pragma once
#include <string>
using namespace std;
class Node;
class Arc
{
public:
Arc(Node &p_destination, const string &p_mode);
~Arc();
private:
string m_mode;
Node* m_destination;
};
Node.h
#pragma once
#include <string>
#include <vector>
using namespace std;
class Arc;
class Node
{
public:
Node(const string &p_name, const int &p_identifier, const float &p_latitude, const float &p_longitude);
~Node();
void set_arcs(Arc* p_arc) { m_arcs.push_back(p_arc); } //Line that causes the error
private:
std::vector<Arc*> m_arcs;
//Other Private Variables removed
};
ヘッダファイルは、両方の対応するCPPファイルに含まれています。この問題に関するいかなる助力も非常に高く評価されます!
編集:
"Syntax Error: identifier 'Arc'"
どのように 'Arc'に' Node'型のメンバがあり、 'Node'にメンバ型' Arc'があるのですか? – EdChum
([* C++で "namespace std"を使用するのはなぜ悪い考えですか?*](http://stackoverflow.com/questions/1452721/why-is-using-namespace-std-in-c-considered-bad-練習)) – Biffen
@LoadData 'Node :: set_arcs'の実装を' .cpp'ファイルに入れることはできませんか? – Biffen