1
votes

In an effort to simplify the problem I am having, I have included two classes in foo.mqh and bar.mqh.

When I compile them, I get:

'bar' - wrong parameters count  foo.mqh Line 20 Column 9

which is this line in foo.mqh:

foobar(bar  & b) { example = b;} 

I have read up on other posts that deal with this error, but they don't seem to be object oriented and I can't correllate those instances with this one.

Is it that bar has a default value? .... because of the constructor? Actually that is probably not it because if I put them in the same file I get the same error.

Is there anyway to get around this?

Any help would be appreciated. Thanks


bar.mqh

#property copyright "Copyright 2015, MetaQuotes Software Corp."   // 01
#property link      "https://www.mql5.com"                        // 02
#property strict                                                  // 03
                                                                  // 04
class bar{                                                        // 05
   private:                                                       // 06
      int b;                                                      // 07
      int u;                                                      // 08
      int g;                                                      // 09
   public:                                                        // 10
      bar * operator=(const bar & example)                        // 11
      {                                                           // 12
         b = example.b;                                           // 13
         u = example.u;                                           // 14
         g = example.u;                                           // 15
         return  GetPointer(this);                                // 16
      }                                                           // 17
      bar(bar & example)                                          // 18
      {                                                           // 19
         b = example.b;                                           // 20
         u = example.u;                                           // 21
         g = example.u;                                           // 22
      }                                                           // 23
                                                                  // 24
};                                                                // 25

foo.mqh

#property copyright "Copyright 2015, MetaQuotes Software Corp."   // 01
#property link      "https://www.mql5.com"                        // 02
#property strict                                                  // 03
                                                                  // 04
                                                                  // 05
#include<bar.mqh>                                                 // 06
                                                                  // 07
class foo {                                                       // 08
};                                                                // 09
                                                                  // 10
class foobar: public foo {                                        // 11
    private:                                                      // 12
        bar example;                                              // 13
    public:                                                       // 14
        foobar(bar  & b) { example = b;}                          // 15
        bar getExample() { return example; }                      // 16
};                                                                // 17
1
The issue was I didn't have constructor/destructor declarations in bar.revivalfx
I think the shared values of the StackOverflow Community shall make you post not only your initial problem statement, but also the solution for the problem, in case, you have found any progress ( if not the solution ) before some other posts answer / comment on your subject. Isn't that fair, revivalfx?user3666197
Sounds fair. That was the intent of my previous comment.revivalfx

1 Answers

1
votes

The issue was that I did not have a constructor/destructor declaration.

See bar.mqh below:

   //+------------------------------------------------------------------+
   //| bar.mqh                                                          |
   //| Copyright 2015, MetaQuotes Software Corp.                        |
   //| https://www.mql5.com                                             |
   //+------------------------------------------------------------------+
   #property copyright "Copyright 2015, MetaQuotes Software Corp."
   #property link "https://www.mql5.com"
   #property strict
   class bar{
   private:
      int b;
      int u;
      int g;
      public:
         bar() {}
         ~bar() {}
         bar * operator=(const bar & example)
         {
            b = example.b;
            u = example.u;
            g = example.u;
            return GetPointer(this);
         }
         bar(bar & example)
         {
            b = example.b;
            u = example.u;
            g = example.u;
         }
   };

foo.mqh did not have to change.