Thread: Is it possible to redefine symbols, e.g. '!' or '~'?

  1. #1
    Registered User
    Join Date
    Oct 2020
    Posts
    19

    Is it possible to redefine symbols, e.g. '!' or '~'?

    Hi everyone,

    I was wondering if it's possible to redefine ! to mean 'call my factorial function on the preceding value' and, because ! usually means 'not', redefine ~ to mean 'not'. I won't need to take any complements (which would require ~), so that won't be a problem. I know that we can't use #define for anything except letters, numbers and underscores.

    How would I go about this?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    No, C does not provide user-defined operator overloading.
    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. How to redefine a constructor from parent class
    By marcoesteves in forum C++ Programming
    Replies: 10
    Last Post: 07-17-2014, 04:47 PM
  2. redefine error (multiple files)
    By help_seed in forum C++ Programming
    Replies: 1
    Last Post: 11-30-2009, 01:12 PM
  3. #redefine??
    By MK27 in forum C Programming
    Replies: 4
    Last Post: 04-09-2009, 12:14 PM
  4. Trying to redefine library #defines
    By Mario F. in forum C++ Programming
    Replies: 4
    Last Post: 06-18-2007, 07:30 AM
  5. redefine cout to directing one file, is impossible?
    By toysoldier in forum C++ Programming
    Replies: 8
    Last Post: 08-19-2004, 11:27 AM

Tags for this Thread