The existing compilation model of C++ templates---namely inlining---suffers from a problem that each object code and the resulting executable tend to become huge, and also, that implementations of templates cannot be hidden. In this paper, we present a method of separately compiling C++ templates. This method is based on source-to-source transformation of C++ code. At runtime, the transformed code (1) performs boxing and unboxing on polymorphic data (as many ML compilers do) in order to deal with the parametric polymorphism of templates and (2) passes around overloaded functions (as the Glasgow Haskell Compiler does) in order to treat the ad hoc polymorphism of C++. Our method also exploits the multiple inheritance and abstract interface mechanisms of C++ to handle method invocations on polymorphic objects.