For Java there are quite a few UML tools (Omondo, ArgoUML, everything but the kitchen sink Visual Paradigm and many others), they can as well generate code from the diagrams. As C++ goes try to ask Oncle Google if he knows any UML tools that generate C++ code.
If you are using Visual Studio (I know its not free but it is popular and you might know someone with a copy) it comes with a UML toolkit since 2003 iirc, although it might be new to 2005. I never use the thing and am at work where I can't check exactly where it is on Start Menu etc... but it does exist. I have never used these tools so they might not support vanilla C++ and only C++ .net considering how Microsoft generally are like that. It might come with the free version on Visual C++ .net too, but I can't be sure without downloading it as there appears to be little information on the ms webpage about it...