The C++ programming language is one of the most popular programming languages and often features among the two three languages on any lists. If you don’t know this wonderful C++ language, and you start reading this, don’t be hesitant to learn C++, we can teach you! Where we should start to do C++ programming? In this post we explain simply how to learn C++ and run simple applications from the very first steps.
Table of Contents
How do you run a C++ program with an IDE ?
If you want to develop a windows application the easiest way is to use a special code editor known as a C++ IDE and C++ compiler that you can use to edit and compile your code into an executable windows application – the actual program that your users will run.
C++ is a powerful programming language with many features that enable you to write almost any app you could ever want. Using a fast and reliable C++ Compiler and IDE is very important for beginners and professionals to develop C++ apps for Windows and other operating systems. When a user wants to develop modern C++ applications, they should learn to use a professional IDE.
An C++ IDE or integrated development environment (IDE) is a software application that provides a complete set of features and tools for application development. Code is generally written in text format – you could easily edit or modify your code using text editors like Notepad, Word, WordPad, UltraEdit or similar, but for a developer, beginner or professional, however, an IDE is really important because it includes lots of helpful features like highlights, auto code completion and a C++ help system. The C++ IDE allows you to run, test, debug, deploy, merge or transform code in one place using an environment which is specially created to work with C++ code and programs. If you wish to target other platforms such as mobiles devices like phones and tablets, or alternative desktop operating systems like macOS or Linux then choosing a C++ IDE which can support all of these in one place is vital.
How do you run a C++ program with the free C++ Builder CE ?
If you are new to C++ and want to compile code for the first time we recommend you try the free C++ Builder Community Edition for students, beginners, and startups. C++ Builder is the easiest and fastest C and C++ IDE for building simple or professional applications on the Windows, macOS, iOS & Android operating systems. It is also easy for beginners to learn with its wide range of samples, tutorials, help files, and LSP support for code. C++ Builder comes with Rapid Application Development Studio, also known as RAD Studio, and C++ Builder is one of the most professional IDE’s that work under RAD Studio. RAD Studio’s C++ Builder version comes with the award-winning VCL framework for high-performance native Windows apps and the powerful FireMonkey (FMX) framework for cross-platform UIs. More details about C++ Builder & RAD Studio for the beginners can be found in Official Wiki of Rad Studio.
So, RAD studio ticks all those wishing to start a C++ program – it is dedicated to the task of writing, testing and debugging C++ programs for Windows, macOS, Linux and mobile devices. It has lots of samples and examples to really give you a boost and help is just a click away.
Here are the features of the C++ Builder CE version;
- Build Windows and iOS C++ Applications 10x Faster with Less Code.
- C++Builder Community Edition provides you with an integrated toolchain and professional-level developer tools from Day 1
- Featuring Clang-enhanced compiler, Dinkumware standard library, MSBuild/CMake/Ninja support, and popular libraries like Boost and Eigen.
- Develop Windows and iOS applications with a single codebase and responsive UI
- Enjoy the award winning Visual Designer using the C++Builder VCL and FireMonkey frameworks for maximum productivity
- Built-in Debugging Tools that allow you to debug on any device
- Build database apps with local/embedded capabilities
- Hundreds of included components to enhance your app and reduce development cycles
- Direct access to InterBase, SQLite, MySQL, SQL Server, Oracle, PostgreSQL, DB2, SQL Anywhere, Advantage DB, Firebird, Access, Informix, MongoDB, and more.
- Licensed for use until your individual revenue from C++Builder applications or company revenue reaches $5,000 US or your development team expands to more than 5 developers
C++ Builder CE is the easiest and fastest C & C++ IDE for developing simple or professional applications on different operating systems. It is also easy for beginners to learn with its wide range of samples, tutorials, help files and LSP support. C++ Builder comes with Rapid Application Development Studio, also knowns as RAD Studio, and C++ Builder is one of the most professional IDEs that work under RAD Studio.
You can download the free C++ Builder Community Edition here: https://www.embarcadero.com/products/cbuilder/starter.Professional developers can use the Professional, Architect or Enterprise versions of C++ Builder. Please visit https://www.embarcadero.com/products/cbuilder.
How do you run a C++ program that uses FireMonkey in C++ Builder?
RAD Studio’s C++ Builder version comes with the award-winning VCL framework for high-performance native Windows apps and the powerful FireMonkey (FMX) framework for cross-platform UIs. Let’s start to develop a C++ app with GUI y using FireMonkey framework.
How to create a new C++ project?
If you download C++ Builder Community Edition (or RAD Studio CE version) or any Professional, Architect, Enterprise versions of C++ Builder. Install it on your windows computer and run RAD Studio or C++ Builder. Beginners and students normally start to learn C++ with simple code. Let’s create a new Multi-Device (Cross-Platform) C++ application by using FireMonkey (FMX) framework.
Choose File->New-> “Multi-Device Application – C++ Builder” menu.
This will create a New C++ Project for Windows and can be easily compiled for other operating systems like iOS , Android. This will allow you develop C++ apps with FMX UI elements. If you don’t need UI Elements, this means you don’t need VCL or FMX frameworks, you create a console application too. Modern applications have a GUI’s and skinned Styles. Note that VCL projects are Windows only and FireMonkey projects are Multi Device (multi-platform) applications that you can compile and run on Windows, MacOS, iOS and Android .
Save all Unit files and Project file to a folder.
How to design your first screen or form when you start a C++ program?
Simply drag and drop components from the Palette window on the right side; Memo (TMemo) and Button (TButton) to your form design. Arrange their width, height and position. You can edit each of their properties from the Object Inspector on the left side.
Note that you can switch between the GUI Design mode to Code Mode by pressing F12, or vice versa. If you want, you can switch to your header file (.h) of your cpp file (.cpp) from the button tabs. You can change your Build Configuration from the left Project window by setting it to Debug or Release mode.
How to add your C++ code to your first C++ program?
Double click to Button1 to create OnClick() event for this button. Add these lines into Button1Click() event,
String str = "Hello World";
This example above is a modern “Hello World” example for Windows which runs with C++ Builder.
How to compile and run a C++ program?
Now you can compile this C++ code; just press the F9 key or just click the Run button in the center of top bar. This will let the IDE check your code and compile both the Unit and project files and link them together. You can also use the Run menu from the top to run your application.You should see this below as a form application
If you get an error, check your code – it’s easy to mistype or have the braces (“}” characters) in the wrong place. Note that C++ is case sensitive, so upper and lower characters should be also same. Then press the F9 key or just click the Run button again.
From this point, you can add more codes or you can switch back to design mode by pressing F12. And you can add more components, then more codes. This is how modern C++ coding works with an UI Toolkit. You can try this simple “Hello World” example below too,
How do you run a C++ program using the VCL?
If you succeed in the steps above and want to know how to compile modern and visual application in VCL, you can do same with a VCL application. Note that VCL applications are only for Windows operating system, you can not compile for other operating systems. There are slight changes between VCL and FMX components.
Now let’s create a Visual and Modern C++ example in C++ Builder,
- Open C++ Builder or RAD Studio IDE
- Create a new Windows VCL Application in C++ Builder from File->New menu. This will allow you develop C++ apps with VCL UI elements.
- Save all units and project files with “HelloWorld_” prefix in a HelloWorld folder.
- Add a Memo (TMemo) and a Button (TButton) from the Palette to your Form. TMemo component is good to display all outputs as in console applications.
- Double click the Button to create OnClick() event, inside that Button1Click event write lines as given in the example below,
- Run project by hitting F9 or click Run with Debugging
- If there is error, please check your lines
- If all is fine then save all project
- if you check your header file you will see all your objects (Memo, Button etc. ) are automatically defined as below. You don’t need to change anything here
If you are a beginner “Hello World” examples are good to understand features of that programming language. It is good to understand how to edit text, how to write in its format, how to compile and link, how to debug and execute, and how to deploy or release the finished program.
This example below is a modern “Hello World” example on Windows which runs with C++ Builder.
You can download the free C++ Builder Community Edition here: https://www.embarcadero.com/products/cbuilder/starter.
Professional developers can use the Professional, Architect or Enterprise versions of C++ Builder. Please visit https://www.embarcadero.com/products/cbuilder.
The latest posts along with more examples and tutorials can be found on the main Embarcadero Blog with this dynamic search https://blogs.embarcadero.com/?s=C%2B%2B and in LearnCPlusPlus.org.