Skip to content

How to avoid the duplicate statement of virtual function in the descendant? #120

@lavender-lee

Description

@lavender-lee

For example, for the interface-like class AdvApprox_ApproxAFunction

class AdvApprox_EvaluatorFunction 
{
  
  //! Function evaluation method to be defined by descendant
  virtual void Evaluate (Standard_Integer *Dimension,
		         Standard_Real     StartEnd[2],
                         Standard_Real    *Parameter,
                         Standard_Integer *DerivativeRequest,
                         Standard_Real    *Result, // [Dimension]
                         Standard_Integer *ErrorCode) = 0;
}

This interface owns 17 descendants, and the virtual void Evaluate() statement are included in each sub-class.

image

image

image

and so on.

I am a developer of java/scala. It is amazed to see that we need to restate the abstract function/interface in the subclass.

interface AdvApprox_EvaluatorFunction {
    void Evaluate (Standard_Integer Dimension,
		           Standard_Real     StartEnd[2],
                           Standard_Real    Parameter,
                           Standard_Integer DerivativeRequest[],
                           Standard_Real    Result[], // [Dimension]
                           Standard_Integer ErrorCode);
}

class Approx_SweepApproximation_Eval implements AdvApprox_EvaluatorFunction {
   
   @Override
   void Evaluate (Standard_Integer Dimension,
		           Standard_Real     StartEnd[2],
                           Standard_Real    Parameter,
                           Standard_Integer DerivativeRequest[],
                           Standard_Real    Result[], // [Dimension]
                           Standard_Integer ErrorCode)  {
    // implementation
    // -------------------
  }
    
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    1. CodingCoding rules, trivial changes and misprints2. QuestionFurther information is requested3. Help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions