explicit operator names

This is a discussion on explicit operator names within the C++ Programming forums, part of the General Programming Boards category; Explicit operators These are keywords for bitwise and logical operators. Non-U.S. programmers without keyboard characters like & , | , ...

  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
    Posts
    23,027
    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,806
    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
    22,304
    Or rather, for C++, #include <ciso646>. Visual Studio doesn't support these keywords the way it is supposed to, i.e., without including <ciso646>.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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, 04:19 PM
  2. Explicit keyword
    By Mario F. in forum C++ Programming
    Replies: 5
    Last Post: 06-30-2006, 07:43 PM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 09:39 AM
  4. Implicit and Explicit
    By ripper079 in forum C++ Programming
    Replies: 2
    Last Post: 09-06-2002, 01: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, 10:19 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21