ITPub博客

首页 > > > 模板元编程例子

模板元编程例子

作者:友哥 时间:2018-08-06 19:31:00 0 删除 编辑
#include <iostream>
#include<string>
using namespace std;


template<int N>
class Pow3{
public:
    static const int result = 3 * Pow3<N-1>::result;
};

template < >
class Pow3<0>{
public:
    static const int result =1;
};

int main(int argc, char *argv[]){
    cout << "Pow3<2>::result= "<< Pow3<2>::result << endl;
    return 0;
}

  

简直就是SQL中的语法分析

原文作者:;如有侵权,请联系管理员删除。

上一篇: 起个名字
请登录后发表评论 登录
全部评论

注册时间:2020-05-20

  • 博文量
    276
  • 访问量
    1000