|
|
inheritanceand virtualfunctions.
One of the promises made for C++ was that you could put
off implementation choices to the very end. We are now
going to declare a pure virtual class called Vstack, two
derivations (arrays and linked lists), a main program that
declares stacks of both types and passes them one at a time
to a function that has no idea which type of stack it is
getting. Indeed it handles an Array_stack at the first call
and a Link_stack (a linked list of nodes) on the second.
|
|