Today, while implementing Huffman Codes (http://www.geeksforgeeks.org/greedy-algorithms-set-3-huffman-coding/), I learned a few new Things which I thought must be shared:
- Adding a custom comparator with STL:
- Also in this I learned when and why and how you can overload operators in classes:
- Also we can’t overload operator= using friend : http://stackoverflow.com/questions/2865036/why-cant-we-overload-using-friend-function
- Why Operator Overloading doesn’t work for pointers: http://stackoverflow.com/questions/6171630/why-isnt-operator-overloading-for-pointers-allowed-to-work
Also when overloading operators with friend function, one of them arguments must be an instance of the class or reference to it.
- The Differences between const int *, int * const, int const * const:
- Why cant I pass a non const pointer to a function taking a reference to a pointer to a const as its argument