oop in mql5

 

Hi i am trying to write an EA in mql5 but oop dont work 

example :

/////////////////////////////
////////////// bpnn.mq5 /////
/////////////////////////////
#include "Network.mqh"
CNetwork *bpnnOBJ;
int Handle=INVALID_HANDLE;
int OnInit()
  {
  bpnnOBJ=new CNetwork();
//--- create timer

   EventSetTimer(60);
      
//---
   return(INIT_SUCCEEDED);
  }

/////////////////////////////
////////// Network.mqh /////
/////////////////////////////
#include "Layer.mqh"
class CNetwork
  {
private:
CLayer m_layers[];
double m_error;

public:
                     CNetwork();
                    ~CNetwork();
                    void FeedForward(const double &inputVals[]) ;
                    void BackPropagate(const double &targetVals[]);
                    void getResults(double &resultVals[])const;
  };

/////////////////////////////
////////// Layer.mqh /////
/////////////////////////////
#include "Neuron.mqh"
class CLayer
  {
private:
CNeuron m_neurons[];
public:
                     CLayer();
      
              ~CLayer();
  };

/////////////////////////////
////////// Neuron.mqh /////
/////////////////////////////
#include "Layer.mqh"
#include "Connection.mqh"

class CNeuron
  {
private:
CConnection m_connections[];
public:
                     CNeuron();
                    ~CNeuron();
                    void feedForward(const CLayer&);
                        // double getOutputVal() const;
  };
void CNeuron::feedForward(const CLayer &pLayer)
{
}
/////////////////////////////
////////// Connection.mqh /////
/////////////////////////////
class CConnection
  {
private:

public:
       double weight;
            double deltaWeight;
       CConnection();
       ~CConnection();
  };

 but when i try to compile the code i get the following errors :

'CLayer' - declaration without type     Neuron.mqh      22      44
'&' - comma expected    Neuron.mqh      22      50
'CLayer' - declaration without type     Neuron.mqh      38      33
'&' - comma expected    Neuron.mqh      38      40
'CLayer' - structure identifier cannot be used  Neuron.mqh      38      33
any ideas?
 

It seems you need a forward declaration. Try to use some advices from this topic.

Also you may take a look at source codes of the following article to get a notion about declaration of several dependant classes.

 
marketeer:

It seems you need a forward declaration. Try to use some advices from this topic.

Also you may take a look at source codes of the following article to get a notion about declaration of several dependant classes.

you mean adding header files of other classes is not enough؟
 
pumper:
you mean adding header files of other classes is not enough؟
I mean you need to declare every class before you can use it. When your classes reference each other there is a cyclic dependence, which should be resolved by forward declaration. You can find details in the abovementioned topic, or in Internet - this is a very common and widely used term in oop.