Class

Oct 21, 2010 at 5:20am
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
Oct 21, 2010 at 5:41am
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!
Oct 21, 2010 at 11:48am
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
Oct 21, 2010 at 4:09pm
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.