I have GetLastError I need a SetLastError

 

Hi All,

I always want to do this funny stuff just before I need to go to work, so if you can help, please do, if not net...enjoy your weekend :)
I wrote my own class an in the constructor I set out different rules for the class to "initialize" if these conditions aren't met I would like for the class to not initialize. I approaches this by doing the following:

 

                          CExperBase(CSignal *signal,long magicNumber, long deviation)
                         { 
                           Signal = signal;
                           ClearTradeValues();
                           Magic = magicNumber;
                           Deviation = deviation;
                           if(signal.Init()!=0)
                           {
                              printf("There was an error initializing the siganl. Stopping.");
                                    }
                           
                         };

 

As you can see if the signal does not initialize I print an error. I would actually like to not initialize the CExpertBase object in this case, how can I do this? 
Reason for not initializing CExpertBase : I use CExpertBase in a different file and Would like know when there was an error

I had the idea of using the MT5 error structure as this is a class but I don't see a SetLastError...
Please help. I think I might be going against the OO principle for rules of the constructor LOL but yea...

 
ToolMaker:

Hi All,

I always want to do this funny stuff just before I need to go to work, so if you can help, please do, if not net...enjoy your weekend :)
I wrote my own class an in the constructor I set out different rules for the class to "initialize" if these conditions aren't met I would like for the class to not initialize. I approaches this by doing the following:

As you can see if the signal does not initialize I print an error. I would actually like to not initialize the CExpertBase object in this case, how can I do this? 
Reason for not initializing CExpertBase : I use CExpertBase in a different file and Would like know when there was an error

I had the idea of using the MT5 error structure as this is a class but I don't see a SetLastError...
Please help. I think I might be going against the OO principle for rules of the constructor LOL but yea...


Did you mean this SetUserError() ?
Reason: