首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Metatrader4 4/MQL4 4代码:依赖类的“错误参数计数”

Metatrader4 4/MQL4 4代码:依赖类的“错误参数计数”
EN

Stack Overflow用户
提问于 2015-04-04 21:47:00
回答 1查看 3.3K关注 0票数 2

为了简化我遇到的问题,我在foo.mqhbar.mqh中包含了两个类。

当我编译它们时,我得到:

代码语言:javascript
复制
'bar' - wrong parameters count  foo.mqh Line 20 Column 9

foo.mqh中的这一行是哪一行

代码语言:javascript
复制
foobar(bar  & b) { example = b;} 

我已经阅读了处理这个错误的其他帖子,但它们似乎并不是面向对象的,我无法将这些实例与此相关联。

那个酒吧有默认值吗?.因为构造函数?,实际上可能不是这样,因为如果我将它们放在同一个文件中,就会得到相同的错误。

有什么可以绕开的吗?

任何帮助都将不胜感激。谢谢

bar.mqh

代码语言:javascript
复制
#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

代码语言:javascript
复制
#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
EN

回答 1

Stack Overflow用户

发布于 2015-04-06 16:49:00

问题是我没有构造函数/析构函数声明。

参见下面的bar.mqh

代码语言:javascript
复制
   //+------------------------------------------------------------------+
   //| 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没有必要改变。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29451741

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档