// Author: // // Instantiation file for all the templated classes used in HW 5 // // Putting the instantiation of *all* classes into one file isn't // generally a good idea (you should have class-specific instantiation // files), but is okay for this HW, since there are so few files. // The following lines trick the compiler into generating linkable // object code out of a template. The compiler will >>NOT<< // generate object code out of a template (ie, "instantiate a // template") >>unless<< it has the class/function implementation // (not just the class definition) available to it in the same file. // Thus, I need to provide the compiler with the templated // class/functions's implementation and then manually instantiate // this class/function. See Section 14.7.2 of the C++ standard. // This is very fugly! // Note that we are including the .cc! We need to compile this // instantiation file, not the templated .cc files // These lines provide the compiler with the template code ... #include "BinarySearchTree.cc" #include "BSTNode.cc" // ... and these lines actually instantiate the object code. template BinarySearchTree< int, double >; template BSTNode< int, double >; // #include "AVLTree.cc" // #include "AVLNode.cc" // template AVLTree< int, double >; // template AVLNode< int, double >;