Thread: explicit operator names

  1. #1
    Banned
    Join Date
    Nov 2007
    Posts
    678

    explicit operator names

    Explicit operators

    These are keywords for bitwise and logical operators. Non-U.S. programmers without keyboard characters like &, |, ^, and so on, were forced to use C’s horrible trigraphs, which were not only annoying to type, but obscure when reading. This is repaired in C++ with additional keywords:


    Keyword

    Meaning

    and

    && (logical and)

    or

    || (logical or)

    not

    ! (logical NOT)

    not_eq

    != (logical not-equivalent)

    bitand

    & (bitwise and)

    and_eq

    &= (bitwise and-assignment)

    bitor

    | (bitwise or)

    or_eq

    |= (bitwise or-assignment)

    xor

    ^ (bitwise exclusive-or)

    xor_eq

    ^= (bitwise exclusive-or-assignment)

    compl

    ~ (ones complement)


    If your compiler complies with Standard C++, it will support these keywords.




    I tried with MSVC .Net 2003 and failed to compile!


  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Visual Studio doesn't support these keywords, unfortunately. You may have to define them manually (#define and &&, etc).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Code:
    #include <iso646.h>
    Works in Visual C++ 2005 don't know about others.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Or rather, for C++, #include <ciso646>. Visual Studio doesn't support these keywords the way it is supposed to, i.e., without including <ciso646>.
    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. Interesting behavior with explicit copy constructor
    By Clairvoyant1332 in forum C++ Programming
    Replies: 1
    Last Post: 04-28-2008, 03:19 PM
  2. Explicit keyword
    By Mario F. in forum C++ Programming
    Replies: 5
    Last Post: 06-30-2006, 06:43 PM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. Implicit and Explicit
    By ripper079 in forum C++ Programming
    Replies: 2
    Last Post: 09-06-2002, 12:22 PM
  5. Error: explicit type cast cannot convert 'void* to 'int*'
    By juschillin in forum C++ Programming
    Replies: 5
    Last Post: 09-04-2002, 09:19 AM