阶乘。。。。。用模板实现 C++

1766阅读 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 };
};

template<>
struct C<1> {
    enum { value = 1 };
};

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

上一篇:ArrayPtr.cpp______Array
下一篇:阶乘。。。。。用模板实现 C++(2)