Thread: operator overload doubt

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    222

    Thumbs up operator overload doubt

    which operators below can be overloaded as class member and non meber function in c++ ?
    1) +
    2) ()
    3) []

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    All of them.

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Virtually all decent introductory material about C++ deals with this - and with most of the questions you've started threads for.

    Since you clearly expect other people to do the hard work of learning and thinking for you, welcome to my ignore list.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  4. #4
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Quote Originally Posted by grumpy View Post
    Since you clearly expect other people to do the hard work of learning and thinking for you, welcome to my ignore list.
    Nah. He's just testing us.
    Kurt

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    whiteflags failed the test though: none of them "can be overloaded as (...) non meber function".
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    I somehow forgot that friends count as members of the client class. Not that they have to be friends.

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Heh, I'm just playing with a typo.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. need help with overload operator[]
    By effa in forum C++ Programming
    Replies: 8
    Last Post: 10-09-2009, 06:30 AM
  2. operator overload
    By maxcat in forum C++ Programming
    Replies: 2
    Last Post: 03-17-2008, 05:07 AM
  3. Operator overload
    By Gordon in forum C++ Programming
    Replies: 3
    Last Post: 03-11-2008, 01:20 PM
  4. overload operator<
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 12-12-2001, 03:54 PM
  5. how to overload [] operator?
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 10-19-2001, 09:49 PM