Class

Hi,
Just want to ask what is meant by this:
1
2
3
4
CSampleClass & CSampleClass::operator = (CSampleClass & node)
{
  ....
}


Why an ampersand is present?

thanks and hope you can enlighten me.

g
http://cplusplus.com/doc/tutorial/pointers/#reference

It's related to pointers so read the above link then ask what you don't understand..

Good luck!
Actually not: It's the reference declaration token, not the reference operator
http://cplusplus.com/doc/tutorial/functions2/

One note, the right operand of operator= should be an rvalue, you should pass node by const reference or by value
The copy operator is one of the four functions that is generated for you if you don't specify them. If you don't specify
CSampleClass& CSampleClass::operator=(const CSampleClass & node)
the compiler thinks you don't have a copy operator and generates one for you, which can get confused with yours.
Topic archived. No new replies allowed.