主要内容

clibgen.api.ConstructorDefinition

R2026b

MATLAB definition for C++ class constructor

Since R2026b

    Description

    A clibgen.api.ConstructorDefinition object represents the MATLAB® definition of a C++ constructor.

    Creation

    ctor = classDef.Constructors creates a constructor definition object from the Constructors property of a clibgen.api.ClassDefinition object.

    ctor = classDef.Constructors creates a constructor definition from the IncompleteConstructors property.

    Properties

    expand all

    This property is read-only.

    Name of the C++ class that contains the constructor, represented as a string scalar.

    This property is read-only.

    MATLAB name for the C++ constructor, represented as a string scalar.

    This property is read-only.

    Fully qualified name of the C++ class that contains the constructor, represented as a string scalar.

    This property is read-only.

    C++ signature of the constructor, represented as a string scalar.

    This property is read-only.

    MATLAB signature for the constructor, represented as a string scalar.

    This property is read-only.

    MATLAB definition of the C++ parameters, represented as a clibgen.api.InputArgumentDefinition object.

    This property is read-only.

    Whether the constructor requires additional definition, represented as Complete or Incomplete.

    Whether this construct is included in the interface, specified as a numeric or logical 1 (true) or 0 (false).

    Doxygen @brief comments for the constructor from the header file, specified as a string scalar. If the header file does not contain @brief comments, the text for Description is:

    MATLABName    Representation of C++ class constructor CPPName.

    Use the Description property to modify the description in the ConstructorDefinition object.

    Doxygen @details comments from the header file, specified as a string scalar. If the C++ file does not contain a comment about the constructor, then DetailedDescription is empty and does not appear in the definition file.

    If DetailedDescription is not empty, then the MATLAB doc command displays the following sentence before displaying the value of DetailedDescription:

    This content is from the external library documentation.

    Use the DetailedDescription property to provide more information about the interface definition file.

    Examples

    collapse all

    icfg = clibgen.api.InterfaceConfiguration("exctors");                                                                                           
    icfg.HeaderFiles = "example_constructors.hpp";                                                                                                  
    icfg.IncludePath = ".";                                                                                                                         
    idef = clibgen.api.InterfaceDefinition(icfg);

    Display complete constructors through the ClassDefinition.

    classDef = findClass(idef,"Rectangle");
    classDef.Constructors
    ans = 
      1×5 ConstructorDefinition array with properties:
    
        OwningClassName
        CPPSignature
        MATLABSignature
        CPPInputs
        Status
        Included
    
      Display as table
    

    If there are multiple constructors, click the Display as table link.

                           CPPSignature                          Status      Included
        ___________________________________________________    __________    ________
    
        "Rectangle::Rectangle()"                               Complete       true   
        "Rectangle::Rectangle(double side)"                    Complete       true   
        "Rectangle::Rectangle(double width,double height)"     Complete       true   
        "Rectangle::Rectangle(double const * dims,int len)"    Incomplete     false  
        "Rectangle::Rectangle(Rectangle const & input1)"       Complete       true   
    
    

    Find a specific overload using findConstructor with input type matching:

    ctor = findConstructor(classDef,CPPInputTypeNames=["double","double"])
    
    ctor = 
    
      ConstructorDefinition with properties:
    
        OwningClassName: "Rectangle"
           CPPSignature: "Rectangle::Rectangle(double width,double height)"
        MATLABSignature: clib.exctors.Rectangle/Rectangle(width, height)
              CPPInputs: [1×2 clibgen.api.InputArgumentDefinition]
                 Status: Complete
               Included: true

    Version History

    Introduced in R2026b