Boost logo

Boost Users :

From: John Maddock (jz.maddock_at_[hidden])
Date: 2008-06-11 04:25:15


Sakaie, Ken wrote:
> I did the following 'hello-world'-level test of the factorial
> function and get the following error.
>
>> cat test.cpp
>
> #include "boost/math/special_functions/factorials.hpp"
> int main()
> {
> unsigned int i = 6;
> printf("%d\n", boost::math::factorial(i));
> }
>
>> g++ -I/home/sakaiek/ext/src/boost_1_35_0/ test.cpp
>
> test.cpp: In function 'int main()':
> test.cpp:5: error: no matching function for call to
> 'factorial(unsigned int&)'

Since the factorial function takes an integer argument and returns a
floating point value, you need to tell the compiler what type of result you
are expecting:

boost::math::factorial<double>(6);

The error message wasn't especially helpful though :-(

HTH, John.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net