In reply to NiLu:
It might help to explain the application you are trying to achieve with this kind of template. Your example has no benefit in being declared as a template; the value W could have been just as easily an argument to the function add, or to the class constructor.