Thread: Function Arguments separated by pipe "|"

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    2

    Question Function Arguments separated by pipe "|"

    I encountered some existing C++ code that made a fuction call with named constant parameters separated by the pipe "|" symbol.

    e.g. function(CONSTANT1 | CONSTANT2 | CONSTANT3 );

    Could someone please explain this syntax to me, Please.

    Thanks in advance.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Read up on bitwise operators in your C book.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    That's the bitwise "or" operator. It or's the bits of its operands together. For example,
    Code:
      1000  (8)
    | 0011  (3)
    ------------
      1011  (11)
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  4. #4
    Registered User
    Join Date
    Sep 2008
    Posts
    2
    Thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  2. Sending multiple arguments to function..
    By Zzaacchh in forum C++ Programming
    Replies: 3
    Last Post: 09-06-2008, 03:20 PM
  3. Help passing arguments to function
    By HAssan in forum C Programming
    Replies: 2
    Last Post: 11-26-2007, 02:15 PM
  4. Arrays as function arguments :(
    By strokebow in forum C Programming
    Replies: 10
    Last Post: 11-18-2006, 03:26 PM
  5. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM