Structures And Functions

From Appmethod Topics
Jump to: navigation, search

Go Up to Structures Index

A function can return a structure type or a pointer to a structure type:

mystruct func1(void);  // func1() returns a structure
mystruct *func2(void); // func2() returns pointer to structure

A structure can be passed as an argument to a function in the following ways:

void func1(mystruct s);        // directly
void func2(mystruct *sptr);    // via a pointer
void func3(mystruct &sref);    // as a reference (C++ only)