C++ OOP friend function

Hi,
I am Peter. I have been learning C++ object oriented programming for about a week. I have some questions about "friend function declaration".

In the following website:
http://www.cplusplus.com/doc/tutorial/inheritance/

friend function is declared as "friend Rectangle duplicate (const Rectangle&);"
I would like to know what is the meaning of " const Rectangle &" ? what type of input argument does this function require?

Likewise, in the function definition - "Rectangle duplicate (const Rectangle& param)" what does "const Rectangle& param" mean?

Can I declare friend function as " friend Rectangle duplicate (Rectangle rect);" ?
what is the difference between declaring as "friend Rectangle duplicate (Rectangle rect);" and "friend Rectangle duplicate (const Rectangle&);" ?

Thanks,
Peter
Please, do not double post. It clutters forums and spreads attempts to help you. Another thread: http://www.cplusplus.com/forum/beginner/168875/
It is a constant reference to rectangle. const denotes that argument is not changed inside function and constant objects can be safely passed to it, and reference means that instead of copying we are creating alias to argument, and all operations are conducted on original object.
http://www.cplusplus.com/faq/beginners/pointers-and-references/
http://www.cplusplus.com/faq/beginners/call-by/
http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/

Can I declare friend function as " friend Rectangle duplicate (Rectangle rect);" ?
what is the difference between declaring as "friend Rectangle duplicate (Rectangle rect);" and "friend Rectangle duplicate (const Rectangle&);" ?
First one (your suggestion) passes argument by value, creating a copy which can become costly if Rectangle class is big enough. Second one passes by reference, avoiding copy.
Topic archived. No new replies allowed.