I want to make something similar to Print(arg1, arg2, ...)
Is it possible or do I need to make n overloaded functions to essentially accomplish the same thing?
You can make arguments optional - for example, Method(type1 name1 = 0, type2 name2 = 0), then call Method(), Method(var1) or Method(var1, var2).
Can't do that in general.
You can make arguments optional. On the right with the "= Constant" and on the left with overloading (See Download
history in MQL4 EA - MQL4 and MetaTrader 4 -
MQL4 programming forum.)
Can't do that in general.
You can make arguments optional. On the right with the "= Constant" and on the left with overloading (See Download
history in MQL4 EA - MQL4 and MetaTrader 4 -
MQL4 programming forum.)
In general, almost all modern languages have a way to implement it including c++, but I assume you are talking about MQL?
I wound up using cascading functions and method chaining.
Example:
class MyClass { public: template<typename T1> MyClass* MyFunc(T1 var1) { // do something return &this; } template<typename T1,typename T2> MyClass* MyFunc(T1 var1,T2 var2) { return MyFunc(var1).MyFunc(var2); } template<typename T1,typename T2,typename T3> MyClass* MyFunc(T1 var1,T2 var2,T3 var3) { return MyFunc(var1,var2).MyFunc(var3); } // ..... etc }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I want to make something similar to Print(arg1, arg2, ...)
Is it possible or do I need to make n overloaded functions to essentially accomplish the same thing?