Make certain that your program declares variables of all possible
RWCollectable objects that you might restore. For an example of this practice, see
Example Two: Restoring Polymorphically, above.
These declarations are of particular concern when you save an
RWCollectable in a collection, then attempt to take advantage of polymorphic persistence by restoring the collection in a different program, without using the
RWCollectable that you saved. If you don't declare the appropriate variables, during the restore attempt the
RWFactory will throw an exception for some
RWCollectable class ID that you know exists. The
RWFactory won't throw an exception when you declare variables of all the
RWCollectables that could be polymorphically restored.
The problem occurs because your compiler's linker only links the code that
RWFactory needs to create the missing
RWCollectable when that
RWCollectable is specifically mentioned in your code. Declaring the missing
RWCollectables gives the linker the information it needs to link the appropriate code needed by
RWFactory.