How to Use C++ Round-Trip Engineering?
Visual Paradigm supports C++ round-trip engineering. It allows you to generate ANSI C++ code from UML class diagram, and to reverse engineer UML class diagram from ANSI C++ code. In this tutorial you will be given a project file, and try to generate ANSI C++ code from it. Then, make change in the code and have the UML class model updated from the code.
Overview of This Tutorial
In this tutorial, we will show you how to perform round-trip engineering of ANSI C++ with a given project file.
To complete this tutorial, you must have Visual Paradigm installed. You also need to have basic knowledge of UML modeling with Visual Paradigm.
Generating ANSI C++ Code from a Class Diagram
- Download Photo-Album-CPP.vpp. You can also find this file at the bottom of this tutorial, under the Resources section.
- Open the downloaded project file in Visual Paradigm.
- Open the class diagram Photo Album. You should see the class diagram below:

- There are a few ways you can generate ANSI C++ code - generate code from a diagram, from selected classes, or for the whole project. In this tutorial, let's try to generate code for the whole project. Select Tools > Code > Generate C++ Code from the toolbar.
- In the Generate Code window, specify the Source Path. You can specify a path by clicking on the cell and then clicking on the ... to open the file chooser for selecting a folder.

- Click OK to generate. Source files are generated to the output path specified.

Updating a UML Class Model from ANSI C++
Once you have finished generating code, you can modify it with your IDE or with any text editor. When you've finished the modification, you can reverse the code-base back to Visual Paradigm to update the UML class model. Let's have a try.
- Open the generated file Location.h in a text editor.
- Let's say we want to add two attributes for the coordinate (x and y) of the location. Let's add two private int attributes x and y.

- Save the changes.
- Let's update our UML model to reflect the change just made. Select Tools > Code > Reverse C++ Code... from the toolbar.
- Uncheck Reverse source on demand at the bottom of the Reverse Code window. If you keep it checked, the UML model won't be updated directly. Instead, an index tree will be formed from the source files specified in the source folder. We want our model updated, so let's uncheck it.

- Click OK. Now, the class diagram is updated, and you should see the two private int attributes x and y added to the Location class.
