How many levels of polymorphism?
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; }
It`s working. Check your code.
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 /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!
- 2011.01.11
- MetaQuotes Software Corp.
- www.mql5.com
May be you create an object of CExpertSignal instead of CSampleSignal class
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.