阶乘。。。。。用模板实现 C++(2)

2264阅读 0评论2011-01-17 jiaxianhua
分类:

// ===============================================
//
//       Filename:  Exam.cpp
//
//    Description:  
//
//        Version:  1.0
//        Created:  2011年01月16日 20时57分14秒
//       Revision:  none
//       Compiler:  g++
//
//         Author:  贾献华 (GNU_hua), jiaxianhua@gmail.com
//        Company:  hisoft
//
// ===============================================

#include
using namespace std;


template
struct C {
    enum { value = n * C::value };
    static const int s_value = n * C::s_value;
};


template<>
struct C<1> {
    enum { value = 1 };
    static const int s_value = 1;
};



int main (int argc, char* argv[]){
    cout << C<7>::value << endl;
    cout << C<7>::s_value << endl;
    return 0;
}

// ----------  end of function main  ----------

上一篇:阶乘。。。。。用模板实现 C++
下一篇:linux pdg reader