How many levels of polymorphism?

 

Hi, is there a restriction on how many levels of polymorphism are possible within MQL5? Using one level of inheritance works OK, but if I specify a second level and try and overwrite those functions, it still uses the ones from the parent class.

 
class CFoo1 { public: virtual string ClassName() { return("CFoo1"); } };
class CFoo2 : public CFoo1 { public: virtual string ClassName() { return("CFoo2"); } };
class CFoo3 : public CFoo2 { public: virtual string ClassName() { return("CFoo3"); } };
class CFoo4 : public CFoo3 { public: virtual string ClassName() { return("CFoo4"); } };
class CFoo5 : public CFoo4 { public: virtual string ClassName() { return("CFoo5"); } };

void OnStart()
  {
   CFoo1 *foo=new CFoo5();
   Print(foo.ClassName());
   delete foo;
  } 
2012.12.19 13:24:05    s2 (USDCHF,H1)    CFoo5

It`s working. Check your code.
 
mql5:

2012.12.19 13:24:05    s2 (USDCHF,H1)    CFoo5

It`s working. Check your code.

Hmm thanks for the reply, if that's working I've clearly made a mistake somewhere else a long the line. Cheers!

 

EDIT: I've been over the code - it all looks OK from here... This code is from the article at https://www.mql5.com/en/articles/226 

You can see my comment right at the bottom there explaining the same apparent issue with the inherited methods,  all i'm trying to do is use CheckOpenLong/CheckOpenShort functions instead of LongCondition and ShortCondition (hence using that article as an example). Sorry to keep asking these questions, but I just keep banging my head on the wall with this problem!

MQL5 Wizard: How to Create a Module of Trading Signals
MQL5 Wizard: How to Create a Module of Trading Signals
  • 2011.01.11
  • MetaQuotes Software Corp.
  • www.mql5.com
The article discusses how to write your own class of trading signals with the implementation of signals on the crossing of the price and the moving average, and how to include it to the generator of trading strategies of the MQL5 Wizard, as well as describes the structure and format of the description of the generated class for the MQL5 Wizard.
 
May be you create an object of CExpertSignal instead of CSampleSignal class
 
mql5:
May be you create an object of CExpertSignal instead of CSampleSignal class
Hmm ok, in this instance I believe my mistake might be defining CheckOpenLong/CheckOpenShort within the customised filter I used - instead this should be done in the customised SIGNAL class, then overwrite the appropriate methods, and reference the filter indicators added in the generated class. I'll have to test it out at the next chance I get. This isn't documented anywhere that I can find, maybe expanding the article I linked to would be an idea?