Thread: pointer to global arithmetic operator?

  1. #1
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838

    pointer to global arithmetic operator?

    possible? google fails me. i'l like to make an operator funtor that doesn't rely on a designator code

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    What do you mean by "designator code" and why does it have to be global.

  3. #3
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838
    by designator code i mean chars containing the ascii representation of the operator.

    global may be the wrong word - i mean operators for POD - int, float, etc. non-class-member operators.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    So you don't want to call it "+"? What do you want to call it, then? Wouldn't it just then be a plain old function?

  5. #5
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838
    Quote Originally Posted by tabstop View Post
    Wouldn't it just then be a plain old function?
    i thought so, it certainly is the case for member operators, their semantics are identical to pointer-to-member functions, but trying it with POD operators yields syntax errors

  6. #6
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    O_o

    I don't understand.

    Show us what you want to do--even if it doesn't work.

    Soma

  7. #7
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838
    argh gotta walk the dogs. brb in like 60 mins...

  8. #8
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    Er. operators on primitive types aren't functions. Rather they are compiled to machine instructions. as such you can't have a pointer to them.

    You can have a pointer to a function that adds two numbers however.

    Does that help?
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  9. #9
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838
    yes that answers my question thx.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pointer Arithmetic and Typecasting
    By pobri19 in forum C Programming
    Replies: 2
    Last Post: 03-19-2009, 11:06 PM
  2. Pointer Arithmetic
    By taurus in forum C Programming
    Replies: 5
    Last Post: 11-14-2008, 03:28 AM
  3. arithmetic operator friend functions
    By linucksrox in forum C++ Programming
    Replies: 7
    Last Post: 02-06-2006, 11:39 PM
  4. Another Linked List plee
    By Dragoncaster131 in forum C Programming
    Replies: 3
    Last Post: 05-15-2004, 05:40 PM
  5. pointer arithmetic
    By new to C in forum C Programming
    Replies: 3
    Last Post: 09-19-2001, 10:06 PM