" & " Pass by reference ?

I was searching to learn more about the friend function when I found this.

___ CODE ____
// friend functions
#include <iostream>
using namespace std;

class Rectangle {
int width, height;
public:
Rectangle() {}
Rectangle(int x, int y) : width(x), height(y) {}
int area() { return width * height; }
friend Rectangle duplicate(const Rectangle&);
};

Rectangle duplicate(const Rectangle& param)
{
Rectangle res;
res.width = param.width * 2;
res.height = param.height * 2;
return res;
}

int main() {
Rectangle foo;
Rectangle bar(2, 3);
foo = duplicate(bar);
cout << foo.area() << '\n';
return 0;
}

At this line friend Rectangle duplicate(const Rectangle&);
const Rectangle&. The & means a pass by reference? Don't we put it before normally ?

Thanks for help !!
The & means a pass by reference?

Yes.

Don't we put it before normally ?

Before the identifier name (which isn't supplied or required in the declaration,) yes.
Oh ! Yes I think I got it. It's the Class name so there is no "Defined" identifier name is this example, that's the & seems like being after, but in fact, it's in front of the supposed identifier name ?
Topic archived. No new replies allowed.