|
-
November 24th, 2009, 08:05 PM
#1
Using an undefined class?
I'm probably going a bit overboard in writing some neural network code as far as OOP goes but I'd like to make it work if possible. The problem I am having is that I have defined classes: CNeuron, CGanglion (a layer in the network), CNetwork, and CLink (a graph edge.... a link from one neuron to another)
In CLink.h I have "class CNeuron;" before it's definition as one of the attributes is a pointer to a neuron. This works out okay. CNeuron.h includes Clink.h, but in CNeuron.h I have a method that uses CGanglion. So I placed "class CGanglion;" prior to my definition of CNeuron.... but now I get an error. If I place this in CLink.h instead I get an error.... it seems wherever I place it I get an error.
D:\Visual Studio Projects\ann\Neuron.cpp(41) : error C2027: use of undefined type 'CGanglion'
Stuff like this makes me still feel like a noob. There must be a solution. Thanks for any help.
Code:
/*************************************/
//CLINK.H
#include <stdlib.h>
#include <time.h>
class CNeuron;
class CLink
{
public:
CLink() {::memset(this,0,sizeof(*this));}
~CLink() {}
double dWeight;
CNeuron *pNeuron;
};
/*************************************/
//CNEURON.H
#include <vector>
#include <cmath>
#include "Link.h"
using namespace std;
namespace afunc {
double identity(double x);
double step(double x);
double bipolar(double x);
double sigmoid(double x);
double bisigmoid(double x);
}
class CGanglion;
class CNeuron
{
public:
void Attach(class CGanglion *pLayer);
void Fire(void);
CNeuron();
virtual ~CNeuron();
double dSummator;
double (*pfActivation)(double);
vector<CLink> vOutput;
private:
void Repolarize(void) {dSummator = 0.;}
};
/*************************************/
//CGANGLION.H
#include "Neuron.h"
class CGanglion
{
public:
void Add(int n,bool b);
CGanglion();
virtual ~CGanglion();
vector<CNeuron> vNeurons;
};
I don't understand why it works for one file but not the other.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|