New Learnings: Custom Comparator with STL, const int * const ptr, reference to pointer to const, Operator Overloading

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:

  1. Adding a custom comparator with STL:
    http://fusharblog.com/3-ways-to-define-comparison-functions-in-cpp/
  2. Also in this I learned when and why and how you can overload operators in classes:
    http://stackoverflow.com/questions/11894124/why-overloaded-operators-cannot-be-defined-as-static-members-of-a-class
  3. Also we can’t overload operator= using friend : http://stackoverflow.com/questions/2865036/why-cant-we-overload-using-friend-function
  4. 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.
  5. The Differences between const int *, int * const, int const * const:
    http://stackoverflow.com/questions/1143262/what-is-the-difference-between-const-int-const-int-const-and-int-const
  6. Why cant I pass a non const pointer to a function taking a reference to a pointer to a const as its argument
    http://stackoverflow.com/questions/20077788/compilation-error-const-int-reference-pointer-to-int-why
    http://stackoverflow.com/questions/5200572/what-does-const-mean-in-context-at-the-end-of-a-function-definition
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s