enum type parameter needs a default value

 

Hi all,

I found that MT4(Build 745) is compulsory requiring enum type variable to have a default value, which is very confused.

Below is my code segment.

enum LineType
{
   UP_TRENDLINE,
   DN_TRENDLINE
};
class FractalLine
{
   private:
      datetime    left, right;
      double      currentValue;
      string      name;
      LineType    type;
   protected:
      virtual void   DrawLine();
   public: 
                     FractalLine();
                     ~FractalLine();
      datetime       GetLeft(){return (this.left);};
      datetime       GetRight(){return (this.right);};
      LineType       GetType(){return (this.type);};
      virtual bool   SetValues(datetime l, datetime r, LineType t);
      virtual bool   IsSameLine(FractalLine &trendline);
};
bool FractalLine::SetValues(datetime l, datetime r, LineType t)
{
   return (true);
}
FractalLine::~FractalLine(void)
{
   if(ObjectFind(this.name)>=0)
      ObjectDelete(this.name);
}

bool FractalLine::IsSameLine(FractalLine &trendline)
{
   if(this.left == trendline.GetLeft() && this.right == trendline.GetRight() && this.type == this.GetType())
      return (true);
   return(false);
}
void FractalLine::DrawLine(void){
   if(ObjectFind(this.name)>=0)
      ObjectDelete(this.name);
   int lBar = iBarShift(Symbol(), PERIOD_CURRENT, left, true);
   int rBar = iBarShift(Symbol(), PERIOD_CURRENT, right, true);
   if(this.type == UP_TRENDLINE)
      ObjectCreate(ChartID(), this.name, OBJ_TREND, 0, this.left, High[lBar], this.right, High[rBar]);
   if(this.type == DN_TRENDLINE)
      ObjectCreate(ChartID(), this.name, OBJ_TREND, 0, this.left, Low[lBar], this.right, Low[rBar]);
}

When I compile, I got the error:

't' - missing default value for parameter    FTL.mq4    27    65
't' - missing default value for parameter    FTL.mq4    30    62
note: the above errors corresponding to the bold codes

Does anyone know why?

 
Yes. Using DOT for variable name is only for MT5. Remove all the DOTs.
 
deysmacro:
Yes. Using DOT for variable name is only for MT5. Remove all the DOTs.

hi deysmacro:

Thanks for your advice

The other parts of code is fine. Also, in the bold segments, I did not use the DOT to call the private member.

Even I remove all the DOTs problems still yet remove.

Ken

 
I do not receive any compile error from your snippet when compiled by 745 nor 749.
 
add a line :
input LineType TL =  UP_TRENDLINE;

this is whithin the documentation, not in the help of editor

 
deysmacro:
Yes. Using DOT for variable name is only for MT5. Remove all the DOTs.

Please don't give wrong advice. DOT can not be used in variables for MT4 AND MT5.

There is not 1 variable with a dot in this code. See documentation.

 

kenykau:

When I compile, I got the error:

Does anyone know why?

  1. When I compiled your posted code, I get no error.
  2. This can be simplified
    datetime GetLeft(){return (this.left);};
    datetime GetRight(){return (this.right);};
    LineType GetType(){return (this.type);};
    
    datetime GetLeft(){return left;}
    datetime GetRight(){return right;}
    LineType GetType(){return type;}
    

Reason: