function call with self created enum -> undeclared identifier (SOLVED!!!)

 

SOLVED !!!!

Hello awesome community,

maybe someone can help me with this simple question. I was not able to find an answer in the forum or to solve this on my own.

I have two Include files: CListofCandles and CPeriod

class CListofCandles
{
 public:         
     
 enum Directions
     {
      Bullish = 1, 
      Bearish = 0 
     };
  
 struct rRates
     {
      double            close;
      double            high;
      double            low;
      double            open;
      datetime          time;
      Directions        direction;
     };

 //--- Variables ---
 rRates               Bar[];

 //---  Functions ---
 void                 Add(MqlRates &Array,Directions ENUM_DIRECTION);
};


void CListofCandles:: Add(MqlRates &Array, Directions ENUM_DIRECTION)
  { 
   Bar[0].close = Array.close;
   Bar[0].open = Array.open;
   Bar[0].high = Array.high;
   Bar[0].low = Array.low;
   Bar[0].direction = ENUM_DIRECTION;
  }

when i try to call a function in CPeriod.mqh from CListCandles.mqh which contains the self created enum i get two errors:

1. Bullish - undeclared identifier

2. Bullish - cannot convert enum


#include <CListofCandles.mqh>

class CPeriod
  {
   public:
   
   // --- Variables ---  
   CListofCandles        Mothers;
   MqlRates              aBar[];

   // --- Functions ---   
   void                  testfunction();
  };

void CPeriod::testfunction()
{
 Mothers.Add(aBar[1],Bullish);
}


 
  


Does someone has any idea how to solve the error 

Best regards

:)

 

Ok i think i got it,

if i use #define instead of enum it works.

 
Benjamin Doerries #:

Ok i think i got it,

if i use #define instead of enum it works.

Don't use #define instead of enum

Just specify enum context

void CPeriod::testfunction()
{
 Mothers.Add(aBar[1],CListofCandles::Bullish);
}
 
Ilyas #:

Don't use #define instead of enum

Just specify enum context

awesome it works :):):):):):)

Thank you very much. 

I was not realy used to specify operators :) Thanks