Circular C++ Header includes [closed]
I'm making a neural net in C++ and i have got a serious problem with headers include look at this code:
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
{
开发者_如何学Pythonpublic:
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;
}
I use VC++2010 and i can't understand why my class Neurone is not recognized by the class Layer. Anyone could help me please ? Thanks,
Neurone.h should not include Layer.h, but rather forward declare Layer: class Layer;
. See the links @Tim refers to.
精彩评论