Thread: Unary + operator

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    2

    Unary + operator

    Hi All,
    Why do we need a unary + operator? Almost all the languages from C, C++, Java support it. What is the use of it?

    Regards,
    Karan S

  2. #2
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Location
    Bangalore, India
    Posts
    345

  3. #3
    Registered User
    Join Date
    Jul 2002
    Posts
    2
    I want to know the use of the unary + operator. See there is a unary - operator which has a use i.e., when applied to a number variable it actually multiplies it by -1 and produces the result.

    But applying a unary + before a variable does nothing. The value remains the same. So why do we need a unary + operator?

  4. #4
    Registered User pinko_liberal's Avatar
    Join Date
    Oct 2001
    Posts
    284
    I dont think it has any practical use either .

  5. #5
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >What is the use of it?
    Symmetry with unary -.

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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. unary operator overloading and classes
    By coletek in forum C++ Programming
    Replies: 9
    Last Post: 01-10-2009, 02:14 AM
  2. Smart pointer class
    By Elysia in forum C++ Programming
    Replies: 63
    Last Post: 11-03-2007, 07:05 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. evaluating unary negation operator in an infix expression??
    By YevGenius in forum C++ Programming
    Replies: 7
    Last Post: 05-12-2004, 01:18 PM
  5. operator overloading and dynamic memory program
    By jlmac2001 in forum C++ Programming
    Replies: 3
    Last Post: 04-06-2003, 11:51 PM