<<< Passing structs to functions | Index | The need for struct pointer >>> |
As written, the normalize() function
void normalize( Rectangle rect ) { rect.set_dimensions( 1, 1 ); }
has no effect on the rectangle declared in main().
By default, in C/C++ the parameters are always passed by value:
a copy of the original object is made before the function is called
the called function works with the copy of the object
the copy is destroyed
the function returns
the original object is never modified
<<< Passing structs to functions | Index | The need for struct pointer >>> |