Download MetaTrader 5
To add comments, please log in or register
Added support for the Spanish language. Come and check it out!
Mideel
74
Mideel 2015.05.24 08:39 

I have this class OrderInfo


Why is it if I use


orderInfo = new OrderInfo() ;

orderInfo.setStopLoss( 0 ) ;


Then I pass the OrderInfo object to other object from class Executioner


executioner.setOrderInfo ( orderInfo ) ;


Definition of function setOrderInfo in class Executioner:


public void setOrderInfo( OrderInfo* _orderInfo ) { m_orderInfo = _orderInfo ; }


Inside one of the method of object Executioner:


public void functiona()

{

      Print( "Stop loss is: " + m_orderInfo.getStopLoss() ) ;      // its 1 not 0

}



   #ifndef ORDER_INFO
   #define ORDER_INFO
   
   class OrderInfo
   {
      public:
      
      OrderInfo()
      {
         m_price = 0 ;
         m_stopLoss = 0 ;
         m_takeProfit = 0 ;
      }
      
      void clone( OrderInfo* _cloned )
      {
         m_price = _cloned.getPrice() ;
         m_stopLoss = _cloned.getStopLoss() ;
         m_takeProfit = _cloned.getTakeProfit() ;
      }
      
      /* setter and getter methods for take profit and stop loss */
                                                                                    
      void     setStopLoss( int _stopLoss ) { m_stopLoss = _stopLoss ; }               
      void     setTakeProfit( int _takeProfit ) { m_takeProfit = _takeProfit ; }
      void     setPrice( double _price ) { m_price = _price ; }
      int      getStopLoss() { return m_stopLoss ; }
      int      getTakeProfit() { return m_takeProfit ; } 
      double   getPrice() { return m_price ; }
      
      private:
      
      /* stop loss and take profit */
      
      double   m_price ;
      int      m_stopLoss ;
      int      m_takeProfit ;
   } ;
   
   #endif
whroeder1
13590
whroeder1 2015.05.24 12:22  

Add a Print statement inside setStopLoss and you will see that the method is called after orderInfo.setStopLoss( 0 ) and before m_orderInfo.getStopLoss().

Run it under the debugger with a break point on the return. Find out where.

/
To add comments, please log in or register