Thread: Yet Another Of My Stupid Questions

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    265

    Yet Another Of My Stupid Questions

    What would it take to add your own operator? I have a feeling the answer is something along the lines of "an act of god" (meaning writing your own language would be faster), but i feel i should just ask anyways. If i wanted to assign the @ character for example, as an operator for add seven to the number like a postincriment operator or something, is there any way to hijack a character and turn it into an operator? Thanks for your (now wasted) time.

  2. #2
    Master of the Universe! velius's Avatar
    Join Date
    Sep 2003
    Posts
    219
    You cannot create your own operators unless you write your own programming language.
    While you're breakin' down my back n'
    I been rackin' out my brain
    It don't matter how we make it
    'Cause it always ends the same
    You can push it for more mileage
    But your flaps r' wearin' thin
    And I could sleep on it 'til mornin'
    But this nightmare never ends
    Don't forget to call my lawyers
    With ridiculous demands
    An you can take the pity so far
    But it's more than I can stand
    'Cause this couchtrip's gettin' older
    Tell me how long has it been
    'Cause 5 years is forever
    An you haven't grown up yet
    -- You Could Be Mine - Guns N' Roses

  3. #3
    Registered User
    Join Date
    Jul 2003
    Posts
    450
    Why would you want to do this when you can overload the exisiting operator anyway?

  4. #4
    Registered User
    Join Date
    Feb 2003
    Posts
    265
    If i overload an existing operator for example using the integer post incriment operator to add 7 instead of 1, my code would become incompadible with other code, and probablly break it. To do it properly i would have to write wrapper classes for all the standard datatypes, and instead of using standard datatypes, use the wrappers in all instances, which would really be re-inventing the wheel vs just inventing a new operator to do whatever i wanted. Thats Why.(TM)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple (stupid) questions - no programming
    By jvu in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 02-07-2009, 04:44 PM
  2. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 05:36 AM
  3. Stupid Questions.....
    By Krak in forum C++ Programming
    Replies: 7
    Last Post: 07-08-2005, 03:11 PM
  4. Incredibly Stupid People
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 09-09-2003, 04:12 PM
  5. Companies and their stupid interview questions...
    By Cheeze-It in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 01-30-2003, 06:00 PM