A clean workaround will depend of your real use case. A suggestion :
#property strict class CStrategy; typedef bool (*SignalFn)(CStrategy*); // Global function definitions bool IsBuySignal(CStrategy*ptr) { return ptr.IsBuySignal(); } bool IsSellSignal(CStrategy*ptr) { return ptr.IsSellSignal(); } // Create an abstract base class class CStrategy { public: virtual bool IsBuySignal(void)=0; virtual bool IsSellSignal(void)=0; }; // Derived class class Strat1 : public CStrategy { public: // Implement the required functions bool IsBuySignal(void) { return true;} bool IsSellSignal(void) { return true;} }; void OnStart() { // instantiate a class Strat1 strat1; // Global functions work as expected SignalFn ptrSignalFn; // pointer to a signal function ptrSignalFn = IsBuySignal; if ( ptrSignalFn(&strat1) ) { Print("Is Buy"); } }
Alain Verleyen:
It's a thought. Thanks for the suggestion.
A clean workaround will depend of your real use case. A suggestion :
Alain Verleyen:
A clean workaround will depend of your real use case. A suggestion :
Is it possible to create a pointer to a class method Iint?
class Fer{public: int Iint(int q){return 18;}; Fer(){}~Fer(){} };
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I'm guessing the error message means exactly what it says.
Can anyone suggest a clean work-around?