Questions on OOP (Object Oriented Programming) - page 4

 
VOLDEMAR:

Please explain the actions

namely

why the sign (:) and what do we get with it?

This is such an initialisation.
 

What is the difference ?

vr_trade trade;
//+------------------------------------------------------------------+
void OnTick()
  {
trade.Buy("EURUSD",0.01); // Пример открытия позиции возвращающей тиккет ордера.
  }
//+------------------------------------------------------------------+ 

и

vr_trade *trade;
//+------------------------------------------------------------------+
void OnInit()
{
trade = new vr_trade;
}
//+------------------------------------------------------------------+
void OnTick()
  {
trade.Buy("EURUSD",0.01); // Пример открытия позиции возвращающей тиккет ордера.
  }
//+------------------------------------------------------------------+ 
void OnDeinit(const int reason)
{
delete trade;
} 
 
VOLDEMAR:

Please explain the actions

namely

why the sign (:) and what do we get with it?



followed by a colon followed by an initialisation list
 
VOLDEMAR:

What is the difference ?

и



Difference in being able to manage an object's lifespan
 
stringo:

The difference is the ability to control the lifetime of the object

I understand that in the case of new you can delete the object at any time, but if without it, the object will only be deleted when the function in which the object is called exits, right?
 
hoz:

I take it that in the case of new, you can delete the object at any time, but if you don't, the object will only be deleted when the function in which the object is called exits, right?


Yes
 
VOLDEMAR:

Recommend a couple of textbooks please ... The easiest and most useful in your opinion ...

http://rutracker.org/forum/viewtopic.php?t=4039549

http://rutracker.org/forum/viewtopic.php?t=4639528

 
How to inherit only one method from one class ?
 
VOLDEMAR:
How to inherit only one method from one class ?
Why?
 

Now I've redesigned my class

class vr_trade
  {
private:
   int               openorders(string sy,int typ,double lot,double price);
   string            tip(int typ);
   int               m_magic;
   int               m_slip;
public:
   int               Buy(string sy,double lot);
   int               Sel(string sy,double lot);
   int               BuyLimit(string sy,double lot,double price);
   int               SelLimit(string sy,double lot,double price);
   int               BuyStop(string sy,double lot,double price);
   int               SelStop(string sy,double lot,double price);
   void              MagSlip(int mag=-1,int slip=0);
   vr_MarketInfo    *Log;
                     vr_trade();
                    ~vr_trade();
  };
MqlTick st;
//+------------------------------------------------------------------+
vr_trade:: vr_trade()
  {
   Log=new vr_MarketInfo;
   MagSlip(-1,0);
  }

And added inheritance ... ( I suspect I may be wrong ) from the vr_MarketInfo class.

Class vr_MarketInfo returns information about Point, Digits for the symbol and checks the lot for errors, and many other things I need for work including logging in Excel and on the chart

When using a method like above a list is given when working in Primer.Primer.Primer()

I would like to do something more abbreviated...