Could someone possibly post a brief explanation of the differences between member and nonmember operator overloading?
Duki 552 Nearly a Posting Virtuoso
Recommended Answers
Jump to PostThere's not that much of a difference -- one is a member of a c++ class and the other isn't.
#include <iostream> using namespace std; class MyClass { public: void operator<<(std::string str) { cout << str;} std::string SayHello() {return "Hello\n";} }; // non-member operator ostream& operator<<(ostream& stream, …
Jump to PostDo you understand how function overloading works? If you do then think of operator overloading in the same way. They work because of the different parameters (if they have the same number of parameters then the parameter types must be different). The c++ compiler mangles function names by including the …
All 6 Replies
Duki 552 Nearly a Posting Virtuoso
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Duki 552 Nearly a Posting Virtuoso
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Duki 552 Nearly a Posting Virtuoso

iamthwee
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.