I am not sure if this would help as the library is in Java. But I found it really cool as it is able to detect around 50 languages from the given text and with a pretty good precision level. You may like to have a look at it and as it is open source, you may rewrite the code in C++ and give it back to the open source community if your application requires to be written only in C++.
Here is the link for the same:
http://code.google.com/p/language-detection/
Note: It uses the Apache Nutch and Tika libraries for analysis.