开发者

Circular C++ Header includes [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜