interface as a return signature ?

 

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.

 
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.
 
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.)
 
Try iBase* checkBaseRiskGiven(void);
Reason: