Download MetaTrader 5
To add comments, please log in or register
Sell your applications via the Market. It is secure!
Amir Yacoby
1122
Amir Yacoby 2015.07.25 20:59 

Hi all,

Can you do it?

class a {};

class b : public a
 {
  b(int i):this("explicit call") 
   {
   }
  b(string s)
   {
    str=s;
   }
  }

    
Ovo Cz
2957
Ovo Cz 2015.07.25 21:10  
I bet it is much faster to try yourself than waiting for an answer here. You cannot. You can create a (private) function that gets invoked from both constructors. No this(), no super() in MQL.
Amir Yacoby
1122
Amir Yacoby 2015.07.26 00:42  
thx
whroeder1
13596
whroeder1 2015.07.26 11:55  
For super I use this pattern
class Shared_Pointer_Subscriber : public Shared_Pointer{
#define Shared_Pointer_Subscriber_SUPER Shared_Pointer
 public:
   void     Shared_Pointer_Subscriber(Subscriber* subscriber)           // Ctor
                               : Shared_Pointer_Subscriber_SUPER(subscriber){}
Amir Yacoby
1122
Amir Yacoby 2015.07.26 12:52  

I wanted to call another constructor in the same class, not in super class.

WHRoeder, I didn't understand what you are trying to show.

From what I understand, you are calling the super constructor in Shared_Pointer.

I asked for different thing but still interesting, why are you using the constant for the super class name? Isn't it the same with the actual super class name (Shared_Pointer) instead the precompiler constant?

 

Thanks. 

/
To add comments, please log in or register