2011-03-09 96 views
0

我正在做一個神經網絡在C++和我有一個嚴重的問題,頭包括 看看這個代碼:圓C++頭包括

Neurone.cpp:

//NEURONE.CPP 

#include "stdafx.h" 
#include "Neurone.h" 
#include <cmath> 

using namespace std; 

Neurone::Neurone(Layer* current,Layer* next) 
{ 

} 

Neurone.h :

//NEURONE.H 

#ifndef _NEURONE_H 
#define _NEURONE_H 

#include <vector> 
#include "Layer.h" 

class Neurone 
{ 

public: 
    Neurone(Layer* current,Layer* next);  

private: 

}; 

#endif 

Layer.cpp:

// LAYER.CPP 

#include "stdafx.h" 
#include <vector> 
#include "Layer.h" 

using namespace std; 

Layer::Layer(int nneurone,Layer &neighborarg) 
{ 

} 

Layer.h:

//LAYER.H 

#ifndef _LAYER_H 
#define _LAYER_H 

#include <vector> 
#include "Neurone.h" 

class Layer 
{ 

public: 
    Layer(int nneurone,Layer &neighborarg); 
    //ERROR :C2061 Layer:Syntax error :Bad identifier 

private: 
    //std::vector <Neurone*> NeuronesInLayer; 
    Neurone ANeuron; 
    //ERROR :C2146 Syntax error :wrong identifier 

}; 

#endif 

Main.cpp的:

//MAIN.CPP 

#include "Neurone.h" 
//#include "Layer.h" 

int main() 
{ 
    return 0; 
} 

我用VC++ 2010,我不明白爲什麼我的類神經元是不是由類層的認可。 任何人都可以幫助我嗎? 謝謝,

+0

[頭文件之間的循環依賴]的可能重複(http://stackoverflow.com/questions/2089056/cyclic-dependency-between-header-files) – 2011-03-09 00:59:25

+0

幾乎同樣的問題被問41分鐘前! – 2011-03-09 01:00:44

+0

這傢伙稱他們爲「通知」,懷疑他的搜索打開了「循環」 – Erik 2011-03-09 01:03:02

回答

3

Neurone.h不應包括Layer.h,而是向前聲明層:class Layer;。請參閱@Tim指的鏈接。