为了简化我遇到的问题,我在foo.mqh和bar.mqh中包含了两个类。
当我编译它们时,我得到:
'bar' - wrong parameters count foo.mqh Line 20 Column 9foo.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
}; // 25foo.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发布于 2015-04-06 16:49:00
问题是我没有构造函数/析构函数声明。
参见下面的bar.mqh:
//+------------------------------------------------------------------+
//| 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没有必要改变。
https://stackoverflow.com/questions/29451741
复制相似问题