Create
a class that holds an array of
ints.
Set the size of the array using an untagged enumeration inside the class. Add a
constint
variable, and initialize it in the constructor initializer list. Add a
staticint
member variable and initialize it to a specific value. Add a
static
member function that prints the
static
data member. Add an
inline
constructor and an
inline
member function called
print( )
to print out all the values in the array, and to call the static member function.
In
StaticDestructors.cpp,
experiment with the order of constructor and destructor calls by calling
f( )
and
g( )
inside
main( )
in different orders. Does your compiler get it right?
In
StaticDestructors.cpp,
test the default error handling of your implementation by turning the original
definition of
out
into an
extern
declaration and putting the actual definition after the definition of
A
(whose
obj
constructor sends information to
out).
Make sure there’s nothing else important running on your machine when you
run the program or that your machine will handle faults robustly.
Create
a class with a destructor that prints a message and then calls
exit( ).
Create a global static object of this class and see what happens.
Modify
Volatile.cpp
from Chapter 6 to make
comm::isr( )
something that would actually work as an interrupt service routine.