类的函数模班 博客分类: c++ template
程序员文章站
2024-03-19 11:00:22
...
#include <iostream> class UtilityTool{ public: template< typename alphabet_type> static void method1(){ std::cout << __FUNCTION__ << ": sizeof(alphabet_type)=" << sizeof(alphabet_type) << std::endl; } template< typename offset_type> static void method2(){ std::cout << __FUNCTION__ << ": sizeof(offset_type)=" << sizeof(offset_type) << std::endl; } }; int main(){ UtilityTool::method1<int>(); UtilityTool::method2<unsigned char>(); return 0; }