Can someone please direct me to a nice, easy tutorial regarding the overloading of operators. My textbook isnt very clear and the sites i looked at seemed a bit too complex.
Thanks!
Can someone please direct me to a nice, easy tutorial regarding the overloading of operators. My textbook isnt very clear and the sites i looked at seemed a bit too complex.
Thanks!
Have you tried googling?
Here's a selection that looks good from the first page of
http://www.cs.caltech.edu/courses/cs...e/cpp-ops.html
http://www.csse.monash.edu.au/~jonmc...html/text.html
http://www.functionx.com/cpp/Lesson25.htm
http://www.parashift.com/c++-faq-lit...erloading.html
I didn't spend many seconds on each of those pages, so I can't say I "recommend" any of them
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Or even better, if you have a specific example you need some help with, there are many individuals here who can help you...
But basically, the way to overload an operator follows ( loosely ) this general format:
You have some flexibility in writing your oerators, just be careful to only write operators that make sense and that their return-type and use are intuitive to the end user. In other words overloaded operators shouldn't "confuse" a user.Code:return_type operatorXX( arguments ){ return statements } /* Where XX is the operator in question */
Ubuntu Desktop
GCC/G++
Geany (for quick projects)
Anjuta (for larger things)