Any defined type can be used as a return type.
This includes all basic types:
char
unsigned char
long
unsigned long
short
unsigned short
int
unsigned int
float
double
void * (any kind of pointer works too)
Complex types including:
enumerations:
Code:
typedef enum { VAL_1, VAL_2, VAL_3 } MyEnum;
MyEmum AFunction( ... );
structures:
Code:
typedef struct my_struct { long a; char b; double c; } MyStruct;
MyStruct BFunction( ... ); /* <-- Using the typedef */
struct my_struct BFunction( ... ); /* <-- Using the fully qualified name. */
unions (see struct above with
union instead of
struct)
All these return types can also apply the
const qualifier. Pointers can have a pointer to what is pointed to and the pointer itself.
C++ offers three more possibilities: two types (bool and class) and references.