Tools.h++ Manual

104011 Tandem Computers Incorporated 14-3
14
(class
RWSlist
). It is restricted because only certain member functions of
RWSlist
can be used (those appropriate to stacks) and because the items
to be inserted into the stack must be of type type.
2.
<rw/rstream.h>
is a special Tools.h++ supplied header file that
includes
<iostream.h>
with the appropriate suffix, depending on your
compiler.
3. This line invokes the macro declare which is defined in the header file
<generic.h>
, supplied with your compiler. If called with arguments
declare
(Class, type), it calls the macro Class
declare
with argument
type. Hence, in this case, the macro
RWGStackdeclare
will be called
(which was defined in
<rw/gstack.h>
) with argument
int
.
Note – To summarize, the result of calling the declare(
RWGStack, int
) macro
is that a new class has been created, especially for your program. It will be a
stack of pointers to ints. Its name, for all practical purposes, is
RWGStack(int)
.
4. At this line an instance
gs
of the new class
RWGStack(int)
is created.
5–8. Four
ints
were created off the heap and inserted into the stack. After
statement 8 executes, a pointer to the int "4" will be at the top of the
stack, a pointer to the int "1" will be at the bottom.
9. The member function
entries()
of class
RWGStack(int)
is called to
verify how many items are on the stack.
10. A pointer to an
int
is declared and defined.
11. The stack is popped until empty. The member function
pop()
will
return and remove a pointer to the item on the top of the stack. If there
are no more items on the stack it will return zero, causing the
while
loop to terminate.
12. Each item is dereferenced and printed.