Use static_cast. : static_cast « Development « C++ Tutorial






#include <iostream>
using namespace std;

int main()
{
  int i;

  for(i=0; i<10; i++)
    cout << static_cast<double> (i) / 3 << " ";

  return 0;
}
0 0.333333 0.666667 1 1.33333 1.66667 2 2.33333 2.66667 3 "








5.20.static_cast
5.20.1.Use static_cast.
5.20.2.Using static_cast: base and derived class
5.20.3.Using static_cast: for enum data type