Analytical or numeric? It makes the answer rather different...
I once implemented a pretty good analytical differentiator in Perl...source here:
http://search.cpan.org/src/JONATHAN/Math-Calculus-Differentiate-0.3/Differentiate.pm
And it is a subclass of:
http://search.cpan.org/src/JONATHAN/Math-Calculus-Expression-0.2.2/Expression.pm
Which handles the parsing. You can probably read the comments and understand enough of the code to figure out how to re-create something similar in C++.
Analytical integration is rather harder than differentiation, so I never got around to working on that one.
Jonathan
###
for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
(tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
/(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");