Possible Duplicate:
Template Metaprogramming - Difference Between Using Enum Hack and Static Const
please explain what for is enum
used in following implementation of power template.
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;
I found it on wikipedia. Is there a difference between int
and enum
in this case?