Download C++: A Beginner`s Guide, Second Edition

Transcript
Precedence
Operators
Highest
( ) [ ] -> :: .
! ~ ++ -- - * & sizeof new delete typeid type-casts
.* ->*
*/%
+<< >>
< <= > >=
== !=
&
^
|
&&
||
?:
= += -= *= /= %= >>= <<= &= ^= |=
Lowest
,
Table 7-2 Precedence of the C++ Operators
Module 7 Mastery Check
1. Show how to declare an int variable called test that can’t be changed by the program. Give it an initial
value of 100.
2. The volatile specifier tells the compiler that a variable might be changed by forces outside the
program. True or false?
3. In a multifile project, what specifier do you use to tell one file about a global variable declared in
another file?
4. What is the most important attribute of a static local variable?
5. Write a program that contains a function called counter( ), which simply counts how many times it is
called. Have it return the current count.
6. Given this fragment, which variable would most benefit from being specified as register?
35
C++ A Beginner’s Guide by Herbert Schildt