Peter87 is correct, although <cmath> is of course a whole lot more than just math.h in namespace std. But to answer the question in a way that's useful to you, define "doesn't work". If you're getting a compilation error, post the error message.
I am going to guess that your C++ compiler is pre-C++11 and that your i has type int.
<math.h> has only one overload of pow(), for double arguments. The compiler builds an implicit conversion from int to double and compiles the call.
<cmath> before C++11 had six overloads of std::pow(), none of which accepted int first argument. The compiler would not be able to decide whether to convert 2 to double or to float or to longdouble, and fail.