2011-03-09 100 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指的链接。