Explicit call of constructor from within a constructor?

 

Hi all,

Can you do it?

class a {};

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

    
 
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.
 
thx
 
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){}
 

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. 

Reason: