【发布时间】:2015-04-04 21:47:00
【问题描述】:
为了简化我遇到的问题,我在foo.mqh 和bar.mqh 中包含了两个类。
当我编译它们时,我得到:
'bar' - wrong parameters count foo.mqh Line 20 Column 9
foo.mqh中的这一行:
foobar(bar & b) { example = b;}
我已经阅读了处理此错误的其他帖子,但它们似乎不是面向对象的,我无法将这些实例与这个相关联。
那个栏有默认值吗? ....因为构造函数? 实际上可能不是这样,因为如果我将它们放在同一个文件中,我会得到相同的错误。
有没有办法解决这个问题?
任何帮助将不胜感激。谢谢
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
【问题讨论】:
-
问题是我在 bar 中没有构造函数/析构函数声明。
-
我认为 StackOverflow 社区的 共享价值观 不仅可以让您发布最初的问题陈述,还可以发布问题的解决方案,以防万一您发现任何问题在其他一些帖子回答/评论您的主题之前取得进展(如果不是解决方案)。 这不公平吗,revivalfx?
-
听起来不错。这就是我之前评论的意图。
标签: metatrader4 mql4