So just run something like
perl -pi -e 's/foo/bar/g' *.cpp *.h
in every directory. Or maybe something like
find . -name "*.cpp" | xargs perl -pi -e 's/foo/bar/g'
assuming you're running in a unix-like environment. I'm sure you could do something similar in Windows. (Note that 'find' is different on Windows.)
For tasks like this, C++ is not the ideal language.