Download MetaTrader 5

interface as a return signature ?

To add comments, please log in or register
Abejorro
184
Abejorro  

On my way to an interface-based-design I was stopped again:

//--- Two Basic interfaces
interface iBase
  {
   double getMarketRisk(void); 
   //...
  };
  
interface iPosition
  {
   // simple and working: 
   double addBaseRisk(iBase &firstObject); 

   double getPositionAndMarketRisk(void); 
   //...
  
   // ERROR: 'checkMarketRiskGiven' - cannot instantiate abstract class:  
   iBase  checkBaseRiskGiven(void); 
  };

What is the way to stay abstract beside ordinary return declaration ?

The Implementing-Class is senseless at that point.

Ex Ovo Omnia
3381
Ex Ovo Omnia  
Abejorro:

On my way to an interface-based-design I was stopped again:

What is the way to stay abstract beside ordinary return declaration ?

The Implementing-Class is senseless at that point.


You are returning an object, in such case the object to be returned must have a copy constructor and cannot be abstract.
whroeder1
16336
whroeder1  
Ex Ovo Omnia: You are returning an object, in such case the object to be returned must have a copy constructor and cannot be abstract.
The alternative is to return a pointer to a base class (possibly an interface.)
To add comments, please log in or register