Hi,

I am trying to create a round kind of function, (to round float and double

to int).

In the H file I can do the following with not too much trouble...

//

#include <limits>

#include <math.h>

template<class T>

int round( T x )

{

if(x > std::numeric_limits<int>::max()){

return 0;

}

return (int)(x + (x > 0 ? 0.5 : -0.5));

}

//

//

But how can I define it in the h file and then implement it in the cpp file?

//

// myfile.h

template<class T> int round( T x );

//

// myfile.cpp

template<class T>

int round( T x )

{

// ..

}

And how's my round(...) function looking?

Simon

--

http://urlkick.com/

Free URL redirection service. Turns a long URL into a much shorter one.