Passing object references to functions
Hello all,
I had posted a code regarding operations of matrices leading to a function using these matrix operations iteratively. Here's the post for reference,
http://cboard.cprogramming.com/showthread.php?t=98711
I have implemented the changes to the functions:
Code:
matrix operator+(const matrix &mat2) const ;
matrix operator-(const matrix &mat2) const ;
friend matrix operator*(const matrix &mat1, const matrix &mat2);
friend matrix operator*(const matrix &mat1, float cnst);
friend matrix operator*(float cnst, const matrix &mat1);
matrix operator=(const matrix &mat2);
friend matrix inverse(const matrix &mat1);
friend matrix zeros(int x, int y);
friend matrix identity(int x);
friend void mat_show(const matrix &mat1);
I have a few conceptual questions. In the function declarations, how is "const matrix &mat2" interpreted? Does the sequence of the declaration move from right to left i.e matrix &mat2 is an object to be passed as a reference parameter and then this reference object is declared as a const?
Also, in the first two function declarations, does the const at the end of the declaration after the parameter list result in the return object (a local object called temp declared in the function) converted to a const value before returning?
Thanks.