欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

类的函数模班 博客分类: c++ template  

程序员文章站 2024-03-19 10:21:52
...
 #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;
}

 

类的函数模班
            
    
    博客分类: c++ template