C++ syntax
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: C++ syntax

  1. #1
    Join Date
    Mar 2010
    Location
    Melbourne Australia
    Posts
    454

    C++ syntax

    In this line of C++ code ;

    Code:
     int permissions = (mode == QSharedMemory::ReadOnly ? FILE_MAP_READ : FILE_MAP_ALL_ACCESS);
    what does the question mark mean and the colon mean

  2. #2
    Join Date
    Nov 2006
    Location
    Essen, Germany
    Posts
    1,344

    Re: C++ syntax

    Itīs the ternary operator, itīs syntax is "exp ? A : B". When the exp evaluates to true, its return value is A, else itīs B.

  3. #3
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,068

    Re: C++ syntax

    Quote Originally Posted by aamir121a View Post
    In this line of C++ code ;

    Code:
     int permissions = (mode == QSharedMemory::ReadOnly ? FILE_MAP_READ : FILE_MAP_ALL_ACCESS);
    what does the question mark mean and the colon mean
    Think of it like
    Code:
    if(mode == QSharedMemory::ReadOnly)
        permissions = FILE_MAP_READ;
    else
        permissions = FILE_MAP_ALL_ACCESS;

  4. #4
    Join Date
    Mar 2010
    Location
    Melbourne Australia
    Posts
    454

    Re: C++ syntax

    thank you all as always you have been most helpful

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center