Reference and classes

Hi everybody,
I just started programming with classes.
Everything was fine until when I saw this expression:

MyClass& operator= (const MyClass&);

It was inside the definition of the class "MyClass". I know what are operators and how they should work, but I don't get the use of the "&" before "operator" and of the one before " ) ".

Can anyone explain me?

Thanks
Try reading this, it explains the differences between references and pointers, but I think it has basically what you want.

http://www.cplusplus.com/forum/articles/20193/
I still don't get it...MyClass& operator= (const MyClass&); should be the declaration of the overloading of a operator right? but then what does the first "&" indicate?
for what concerns the second "&", it's the first time I see it used with the postponed notation. Is there any difference?
1
2
3
4
5
6
7
int i; //normal variable
int* p; //pointer
int& r; //reference

int f(); //function returning a normal value
int* g(); //function returning a pointer
int& h(); //function returning a reference 


Now replace all ints with whatever type you want.
Oh, I see...basically I always thought to * and & as referring to a variable, not to the type of the variable.
Many thanks!
Topic archived. No new replies allowed.