2016-08-05 7 views
-5

私は以下のように宣言されたクラスを持っています。私は他の同様の質問を見てきましたが、私の問題の解決策を見つけることができません。どんな助け?前もって感謝します! :)あなたは、円形のを避けることができ"タイプに名前はありません"エラーC++

#ifndef ENTRANCE_H 
#define ENTRANCE_H 
#include "Segment.h" 
#include <vector> 
#include "Diodio.h" 


class Entrance 
{ 
    public: 
     Entrance(); 
     ~Entrance(); 
     void operate(); 


    protected: 
     Segment *givesEntryTo; 
     std::vector<Diodio> elBooths; 
      std::vector<Diodio> manBooths; 

    private: 
}; 

#endif // ENTRANCE_H 
+3

ほとんどの場合、ヘッダー間に循環依存関係があります。 – molbdnilo

+0

推測:Segment.hに直接または間接的にEntrance.hが含まれていますか? – aschepler

+0

これはクラス**の定義**です。クラスの宣言は 'class Entrance;'となります。 – IInspectable

答えて

-1

ではなく#includeのクラスの前方宣言を使用して問題を含める:

#ifndef ENTRANCE_H 
#define ENTRANCE_H 
#include <vector> 
#include "Diodio.h" 

class Segment;  

class Entrance 
{ 
    public: 
     Entrance(); 
     ~Entrance(); 
     void operate(); 


    protected: 
     Segment *givesEntryTo; 
     std::vector<Diodio> elBooths; 
      std::vector<Diodio> manBooths; 

    private: 
}; 

#endif // ENTRANCE_H 

(Entrance.cppはしてもしなくてもよい、その後#include "Segment.H"する必要があるかもしれません。)

関連する問題