Linked Questions
1,394 questions linked to/from What are the basic rules and idioms for operator overloading?
9 votes
1 answer
10k views
Operator overloading inside vs outside class [duplicate]
What is the difference between inside and outside class overloading? class A{ public: bool operator==(const A *i){ .... .... } }; vs bool operator==(const A *i ,...
4 votes
3 answers
4k views
correct way to implement operator== in .cpp file [duplicate]
i have a class which needs to implement the operator== and return type of it is bool. I'm not sure is below code the correct way to implement it. //MyTest.hpp file class Test { public: Test(); ...
2 votes
3 answers
2k views
Return value of assignment operator overloading c++ [duplicate]
I'm new to C++ and I'm starting with learncpp website. In Assignment Operator Overloading chapter has those lines of code: Fraction& Fraction::operator= (const Fraction &fraction) { ...
1 vote
6 answers
1k views
Exactly how do << and >>, as used in streams, work? [duplicate]
I always thought of cout and cin calls as something like this: cout << someVar tells the compiler we're dumping the value of someVar into cout, just as we could dump water into a physical ...
1 vote
4 answers
637 views
Overloading = in C++ [duplicate]
I'm trying to overload the assignment operator and would like to clear a few things up if that's ok. I have a non member function, bool operator==( const MyClass& obj1, const myClass& obj2 ) ...
1 vote
3 answers
5k views
strict weak ordering confusion [duplicate]
I am confused about strict weak ordering and how to use it when defining operator<. I have a couple of structs: struct Plane { std::string name; int xrudder; int yrudder; int ...
0 votes
8 answers
473 views
Purpose of overloading operators in C++? [duplicate]
What is the main purpose of overloading operators in C++? In the code below, << and >> are overloaded; what is the advantage to doing so? #include <iostream> #include <string>...
4 votes
4 answers
1k views
no match for ‘operator ==’ in ‘a == b’ [duplicate]
#include <iostream> using namespace std; class family { private: double weight; double height; public: family(double x,double y); ~family(); double ...
7 votes
1 answer
436 views
Why is no return type specified in this function clearly returns? [duplicate]
Possible Duplicate: Operator overloading I am seeing this in a piece of sample code: operator Vector2<float>() const { return Vector2<float>(x, y); } My 2 questions ...
2 votes
6 answers
406 views
C++ overloading operators difference between == and < [duplicate]
Could anybody explain me what is the difference between overload == and <? For example, if I use a map: map<Type, int> a(); friend bool operator<(const Type& lhs, const Type& ...
3 votes
2 answers
243 views
Struggling to get '==' operator overloading to work (C++) [duplicate]
Okay, not sure what I'm doing here, other than it's not right. Trying to overload the '==' method of a class, and it's just... not working. At least, I get a false back from my main, and the cout in ...
2 votes
1 answer
3k views
Operator overloading performance [duplicate]
I was reading a paper on automatic differentiation and the authors mention: "Likewise, using operator overloading may introduce method dispatches with attendant costs, which, compared to raw numerical ...
0 votes
1 answer
5k views
Overloading a c++ == operator [duplicate]
So i've been told that in order for part of my program to work that I need to overload the == operator, unfortunately I have absolutely no idea how to do this, here is the class for which the operator ...
4 votes
1 answer
2k views
Trying to overload increment operator in C++ [duplicate]
So far every operator works fine except for this one. When I run the code, I get the error: "error: postfix 'Complex Complex::operator++(Complex)' must take 'int' as its argument|" Heres my code: #...
1 vote
7 answers
1k views
operator overloading in c++ [duplicate]
Possible Duplicate: Operator overloading Hi guys can some one please suggest a good tutorial on operator overloading? I was going through this code on operator overloading and I have the following ...