yeah i know i didnt realize that pow wont take or return an int. however my code above will take any int float or double and return int float or double
I don't see the point in writing your own template function to do this, that is what std::pow does - no need to reinvent the wheel.
So osgwsy's solution is the best one.
Personally, I explicitly specify the zero after the decimal point for FP numbers - as in 3.0 but not 3 or 3. (no decimal point, or nothing after decimal point) Doing means the number will be a double by default and is easier to read IMO.
i just did it because it doesnt do ints. it didnt take that long to write and the only issue it could have is making it auto and/or giving it that initial value of base instead of one
Admittedly it is a C++11 thing - people are often not aware of some of the new things. I am only aware of a small fraction of them myself.
If the OP had C++11 enabled & called std::pow instead of pow, the code would have worked as is. No need to write any more code. But osgwsy's solution is by far the simplest.
I guess it is a good lesson to the OP to be aware of types in general & especially when calling functions.
Other than as an exercise, it's not usually a good idea to re-invent the wheel. I don't remember the context, but I saw some other example recently where a library function had been re-written by someone.
Doing that is fine, as a study task. It can be a good way to learn. But the larger issue is that the library functions are thoroughly tested and well-documented. Their properties, including any limitations, are known.
Once one starts writing one's own versions of any function, then all the testing, debugging, optimising and documenting has to be done all over again. Although I'd do that with my own code, if the code came from some other source I'd go for the library version every time.