is there any c++ compiler for ipad2?
No fully functional IDE exists on iOS to make runnable apps without jailbreaking  but you can sign up for a free Amazon Web service account and get an ssh client and program "on the iPad" assuming you have a network account.

An app like nimbus or textastic would be an ideal companion once you were clear how compiling elsewhere fit your desire to learn.

Xcode is currently only available for Mac OS X to develop programs that run iOS and cocoa touch (not which is very much not C++ - even though Xcode can be used for C++).

Have a look at this question on learning C which will apply almost entirely to C++ on iOS.

Is there a C compiler for iPad?