模板编程不允许虚函数的出现。为了使用基类函数,我们只能用转交函数123456789101112template<typename T>class SquareMatrixBase {protected: void invert(std::size_t matrixsize);};template<typename T, std::size_t n>class SquareMatrix : private SquareMatrixBase<T> {private: using SquareMatrixBase<T>::invert;public: void invert() {this->invert(n);}};