template
class Fact {
public:
enum { value = N * Fact
};
//Template specialization
class Fact<1> {
public:
enum { value = 1 };
};
make a obj of Factorial and then retreive the value ,the good thing is no function call is made only expansion at runtime is hapening and its an crisp code ,
Template is very powerful in scientific computing .
You can expect more intresting posts on template shortly.
2 comments:
Very interesting post,had never used templates this way !!
Yes , and this comes under metaprograming and is the basis of BLITZ compilers.
Post a Comment