2012-07-14 2 views
5

가능한 중복은 :
Template Metaprogramming - Difference Between Using Enum Hack and Static Const펑 (전원) 템플릿 구현

입니다 enum 전력 템플릿의 구현을 다음에 사용하는지 설명하십시오.

template<int B, int N> 
struct Pow { 
    // recursive call and recombination. 
    enum{ value = B*Pow<B, N-1>::value }; 
}; 

template< int B > 
struct Pow<B, 0> { 
    // ''N == 0'' condition of termination. 
    enum{ value = 1 }; 
}; 
int quartic_of_three = Pow<3, 4>::value; 

위키피디아에서 찾았습니다. 이 경우 intenum 사이에 차이가 있습니까?

+0

@user를 참조 - 'enum'은'const 정적 int'을 지원하지 않은 볼랜드 C++처럼, 오래된 컴파일러 일했다. –

답변