10 Questions
In the expression (!time > limit)
, if time
is an int
with value 36 and limit
is 60, what is the value of !time
?
0 (false)
What is the correct way to express the intent of checking if time
is greater than limit
?
!(time > limit)
In C++, what is the default value of an uninitialized enumeration constant?
The value is implementation-defined
Which of the following is a valid way to declare a strongly-typed enumeration in C++11 and later?
enum class Color { Red, Green, Blue };
What is the value of static_cast(MyEnum::Value1)
if MyEnum
is an unscoped enumeration type and Value1
is not explicitly assigned a value?
The value is implementation-defined
Which of the following statements is true about strongly-typed enumerations (enum class
) in C++11 and later?
They can have their underlying type explicitly specified
What is the value of static_cast(MyStrongEnum::Value1)
if MyStrongEnum
is a strongly-typed enumeration and Value1
is not explicitly assigned a value?
0
Which of the following is a valid way to initialize a strongly-typed enumeration in C++11 and later?
All of the above
Which of the following statements is true about the !
operator in C++?
It can be applied to any non-boolean value, and the result is 1 (true) if the value is non-zero, and 0 (false) if the value is zero
What is the value of static_cast(MyStrongEnum::Value3)
if MyStrongEnum
is a strongly-typed enumeration with Value1 = 10
, Value2 = 20
, and Value3
is not explicitly assigned a value?
30
Learn about the importance of avoiding the '!' operator in C++ expressions to ensure clarity. Additionally, explore the concept of enumeration types, which are types with values defined by a list of constants.
Make Your Own Quizzes and Flashcards
Convert your notes into interactive study material.
Get started for free