php trader correl,Metatrader4/MQL4代码:与相关类“错误的参数计数”

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

为了简化问题,我在foo中包含了两个类。和公式(由mccaffrey 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:

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

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

foo.mqh

#property copyright "Copyright 2015, MetaQuotes Software Corp." // 01

#property link "https://www.mql5.com" // 02

#property strict // 03

// 04

// 05

#include // 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 个解决方案

#1

1

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

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

See bar.mqh below:

看到酒吧。下面的公式(由mccaffrey:

//+------------------------------------------------------------------+

//| 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.

foo。mqh不需要更改。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值