Automatic guessing on return parameters

 

Automatic guessing on return parameters happens when C++ Developer is generating the code for a return parameter for which the automatic generation flag is set.

 

The following table shows the generated declaration for a return parameter.

 

Return parameter type

Cardinality

Declaration

integer               

0..1

int*

1..1

int

0..*

int*

1..*

int*

n..m

int*

string                  

0..1

std::string*

1..1

std::string&

0..*

std::string*

1..*

std::string*

n..m

std::string*

MyClass             

0..1

MyClass*

1..1

MyClass&

 

0..*

MyClass*

1..*

MyClass*

n..m

MyClass*

MyDatatype      
isPrimitive=true 

0..1

MyDatatype*

1..1

MyDatatype

0..*

MyDatatype*

1..*

MyDatatype*

n..m

MyDatatype*

MyDatatype
isPrimitive=false              

0..1

MyDatatype*

1..1

MyDatatype&

0..*

MyDatatype*

1..*

MyDatatype*

n..m

MyDatatype*

 

Note 1:   Where the table states integer, this can be any basic type (integer, char, float, boolean).

 

Note 2:   Return parameters never return a collection, but simply a pointer to the first element of an array.  This is because we no assumptions can be made by C++ Developer about the internal implementation of the method returning the parameter.  In real life, a reference to the container will most often be returned.

 

Note 3:   For returned values with a minimum cardinality of 0, a pointer is returned, which allows the expression of the absence of any useful value (in which case a null pointer can be returned).