-
June 21st, 2011, 03:36 AM
#1
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
-
June 21st, 2011, 03:48 AM
#2
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.
- Guido
-
June 21st, 2011, 07:18 AM
#3
Re: C++ syntax
Originally Posted by aamir121a
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;
-
June 21st, 2011, 05:06 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|