All Questions

1739
votes
7answers
792286 views

What are the basic rules and idioms for operator overloading?

Note: The answers were given in a specific order, but since many users sort answers according to votes, rather than the time they were given, here's an index of the answers in the order in which they ...
318
votes
7answers
30086 views

Pretty-print C++ STL containers

Please take note of the updates at the end of this post. Update: I have created a public project on GitHub for this library! I would like to have a single template that once and for all takes care...
118
votes
9answers
145858 views

Operator overloading in Java

Please can you tell me if it is possible to overload operators in Java? If it is used anywhere in Java could you please tell me about it.
36
votes
5answers
26906 views

overloading friend operator<< for template class

I have read couple of the question regarding my problem on stackoverflow now, and none of it seems to solve my problem. Or I maybe have done it wrong... The overloaded << if I make it into an in...
81
votes
2answers
68692 views

Operator overloading : member function vs. non-member function?

I read that an overloaded operator declared as member function is asymmetric because it can have only one parameter and the other parameter passed automatically is the 'this' pointer. So no standard e...
167
votes
5answers
250223 views

How to properly overload the << operator for an ostream?

I am writing a small matrix library in C++ for matrix operations. However my compiler complains, where before it did not. This code was left on a shelf for 6 months and in between I upgraded my comput...
219
votes
1answers
18892 views

A positive lambda: '+[]{}' - What sorcery is this?

In Stack Overflow question Redefining lambdas not allowed in C++11, why?, a small program was given that does not compile: int main() { auto test = []{}; test = []{}; } The question was ans...
333
votes
13answers
137723 views

Why doesn't Java offer operator overloading?

Coming from C++ to Java, the obvious unanswered question is why didn't Java include operator overloading? Isn't Complex a, b, c; a = b + c; much simpler than Complex a, b, c; a=b.add(c);? Is there a...
56
votes
4answers
9306 views

How should I write ISO C++ Standard conformant custom new and delete operators?

How should I write ISO C++ standard conformant custom new and delete operators? This is in continuation of Overloading new and delete in the immensely illuminating C++ FAQ, Operator overloading, and ...
65
votes
15answers
34085 views

Operator[][] overload

Is it possible to overload [] operator twice? To allow, something like this: function[3][3](like in a two dimensional array). If it is possible, I would like to see some example code.

Previous Next