Thread: operator overloading query....

  1. #1
    lonelyplanetwanderer
    Guest

    operator overloading query....

    hi there...could any1 help me out with this lil' query on operator overloading (OO)...nothing specific, just general stuff...in order to better map theoritical concepts that i m learning to the real world, i just want to know where and when is the concept of OO applied...what sort of SW projects in which industries require mechanisms such as this to be implemented...

    any advise/suggestions will be greatly appreciated...cheers!

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Operator overloading is really only a way to make the syntax for an interface more user friendly. Saying
    if ( foo == bar )
    is easier and more intuitive than
    if ( equals ( foo, bar ) )

    Or so I've been told. I find it more of a convenience to people who use my libraries, other than that I see no real use in it. Some people will argue against this, and I hope they do because I'm more than willing to look from a different perspective. Hint hint Sorensen.

    -Prelude
    My best code is written with the delete key.

  3. #3
    Unregistered
    Guest
    To borrow from Prelude's response: I think operators make the interface more user friendly:

    if ( foo == bar )
    is easier and more intuitive than use of equivalent function syntax
    if ( equals ( foo, bar ) )


    Overloading operators (functions) allows generalization of concept involved with the operator (or function) from class to class. If == could only be used with type int but not with type float, or char, or STL string class, or an appropriate user defined class the world of programming would be much more hassle filled. Likewise, although it is possible for a given operator or function to mean something completely different when applied from one type to another, it is certainly more useful when it means something similar. What if the word no meant yes in one setting and stop in another? What a mess.

  4. #4
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    >Hint hint Sorensen.

    Alright, I'll bite. Operator overloading is more than just a convenience if you wish to write generic functions that'll work correctly with built in types and user defined types; it's a necessity.

  5. #5
    lonelyplanetwanderer
    Guest

    alright but...

    fair enough...appreciate the feedback...but...to explain my query a lil' more i'll take the example of another mechanism - quicksort...quicksort as compared to bubblesort is far more efficient and faster...so typically a banking application which needs to search thru, for e.g., a million ATM cardholder records would need to definitely implement quicksort...a database for a small school could do away with any code...

    similarly, are there, and correct me if i am way off, any particular instances in terms of SW projects in particular industries where the mechanism of quicksort is not an option but a necessity?

  6. #6
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    >to explain my query a lil' more i'll take the example of another mechanism - quicksort

    What's this got to do with your original query. Your original post was about language syntax, and this is about algorithms.

    >quicksort as compared to bubblesort is far more efficient and faster

    Only for a large enough number of elements.

    >so typically a banking application which needs to search thru, for e.g., a million ATM cardholder records would need to definitely implement quicksort

    Only if it's ATM records were contained in an array type structure.

    >any particular instances in terms of SW projects in particular industries where the mechanism of quicksort is not an option but a necessity?

    I think there's normally an alternative. Strictly speaking, if you wanted performance guarantees in some critical application you couldn't use a straight quicksort as it only guarantees O(n^2).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple query language
    By afflictedd2 in forum C++ Programming
    Replies: 3
    Last Post: 12-04-2008, 05:29 PM
  2. query problem
    By arian in forum C# Programming
    Replies: 1
    Last Post: 08-18-2008, 01:49 PM
  3. DNS Query
    By Simpsonia in forum Networking/Device Communication
    Replies: 1
    Last Post: 04-24-2006, 12:42 AM
  4. dns query
    By bulldog in forum C Programming
    Replies: 6
    Last Post: 02-24-2004, 10:44 AM
  5. WBEM Query too slow
    By Unregistered in forum Windows Programming
    Replies: 0
    Last Post: 10-08-2001, 05:28 PM