cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
operator overloading
operator overloading
Oct 13, 2010 at 1:10pm UTC
Troubled646
(11)
in order to overload << or >> operator, why it is good to use non-member functions rather than member functions of the class?
Oct 13, 2010 at 1:27pm UTC
Mike Sandy
(30)
If you can handle writing something like:
string<<cout and string>>cin
you can use member functions,but not many people will appreciate that when reading your code.Cheers.
Oct 13, 2010 at 1:45pm UTC
coder777
(8444)
Hello Troubled646,
I wouldn't say that has to do with good or bad. It's just when you have control of the class you can write them as members. If you don't have control (such as stl iostreams) you must use the non-member if you want to extend the functionality
Oct 13, 2010 at 3:27pm UTC
Disch
(13742)
+1 to coder777
Topic archived. No new replies allowed.