C++ is probably the most powerful programming language and one of the world’s most popular programming languages with many variables, functions, methods, namespaces and libraries to help you solve a multitude of problems. Using a fast and reliable C++ IDE is very important for beginners and professionals alike to ensure that when they develop C++ apps for Windows – and for other operating systems – the process is as smooth and as efficient as possible. When a user wants to develop modern C++ applications taking the time to learn to use a professional IDE pays dividends in efficiency, accuracy of the final solution and speed. In this post we explain the basics of C++ Builder as a guide for those who are taking those first tentative steps on the path to becoming a developer.
What is an IDE?
An integrated development environment (IDE) is a software application that provides a complete set of features for application development. Code is generally written in text format, and you can easily edit or modify your code using text editors like Notepad, Word, WordPad, etc. For a developer (beginner or professional), however, an IDE is really important because features like highlights, auto code completion and help system, and the opportunity to run, test, debug, deploy, merge or transform code on other platforms (multiplatform coding) are also important. All these capabilities require a powerful IDE.
Step 1. Download the free C++ Builder Community Edition
If you are new to C++ and want to compile a code first time we recommend you 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. It is the oldest IDE (it began as Borland TurboC in 1990 and was later renamed Borland C++ Builder). Under the Embarcadero brand, it comes with new versions, features, updates, and support. 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.
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 which can be found at https://www.embarcadero.com/products/cbuilder.
Step 2. Start creating modern visually appealing C++ applications
Ok, so, there’s a little more to it than downloading the IDE and just getting on with it!
If you want to know how to compile modern, visually appealing applications in C++, you can start with a simple example with some visual components. This first simple application is good to understand how to edit text, how to format the text, how to compile the test application and link it, how to debug the app and execute it, how to deploy or release it ready for your end-users. We will start with a simple app.
Now let’s create a modern C++ example in C++ Builder. In our first application we will create a windows application which has visual input and output UI elements. Our application will get width of a square and it will calculate the area of this square. This simple example helps us understand how C++ Builder integrates with C++ code and its VCL (VisualComponentLibrary) or FMX (FireMonkey) framework. Let’s see the steps to create this application,
- Open C++ Builder or the RAD Studio IDE.
- Create a new Windows VCL Application in C++ Builder. This will allow you develop C++ apps with VCL UI elements. Or you can create a new MultiDevice Application in C++ Builder. You can select both from the File->New IDE menu. Selecting “multi device application” will allow you develop C++ apps which use FireMonkey UI elements to create apps which can work on Windows, macOS, Linux, iOS and Android. However, in this example we will be using the “Windows VCL Application” option which only works on Microsoft Windows.
- Once the initial blank app has been created by the IDE, save all units and project files with “MyFirstApp_” prefix in a HelloWorld folder.
- Now add a Label (TLabel), Edit (TEdit), Memo (TMemo) and a Button (TButton) from the Palette to your Form. When you drag these component classes, they will create class objects of these components: Label1, Edit1, Memo1, Button1. Here our Edit1 object is a good input component to get values. The Memo1 object is good to display all test output as in console applications.
- Click the Memo1 object and find the Lines property from the Object Inspector on the left side. Now click […] (the ellipsis) next to the edit text lines of this Memo. A text editor window will open allowing you to edit the string list. In this String List Editor, delete any default text inside and add “
Welcome to My First App
” or your own choice of words as given below,
Press “OK” to accept and exit from the String List Editor
6. Click the Label1 object, If you are developing VCL C++ app find the Caption
property from the Object Inspector. If you are developing a FireMonkey C++ app find the Text
property from the Object Inspector. Change it’s text value to “Width”
7. Click the Edit1 object, find the Text property from the Object Inspector. Change its text value to “10”. This will be our default text when the application runs.
8. Click the Button1 object. If you are developing a VCL C++ app, find the Caption
property from the Object Inspector. If you are developing a FireMonkey C++ app find the Text
property from the Object Inspector. Change its text value to “Calculate” . Arrange their size and positions by dragging them and by using their corners as shown in the example below,
9. Double click the Button1 (Calculate Button) to create OnClick() event, inside that Button1Click event write lines as given full example below,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#include <vcl.h> #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { // Get Inputs float a = StrToInt(Edit1->Text); // Calculate float area = a*a; // Put Outputs Memo1->Lines->Add( u"Width of Square: " + Edit1->Text ); Memo1->Lines->Add( u"Area of Square: " + FloatToStr( area ) ); } |
Here when user clicks to Button1 (Calculate Button) it will get Input from Edit1, it will calculate the area of the square and we will add the input and output results to the lines of Memo1.
If you are beginner, you can think that inside of this Button1Click() is like the inside of the main()
function or a similar function in C++. In reality it is a method used by the Form1 object class.
10. Run the project by hitting F9 or click Run with Debugging. You can also select Run without Debugging although moat of the time you’re not going to select that while you are writing and testing your program.
This will create a Window Form with your UI elements. You can calculate the area of the square with the given width value. Change the width value to 50 and hit calculate or change to 999 and calculate. The results and the Window Form of our first C++ application should be like this below,
11. If there is an error, please check your lines of code to make sure they match those of our example. The C++ programming language is case sensitive. Also, don’t forget to put “;” (semicolon) at the end of statements and the “{” and “}” begin/end braces.
12. If all is fine then the project
13. if you check your header file you will see all your objects (Label1, Edit1, Memo1, Button1 etc.) are automatically defined as below. You don’t need to change anything here
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
#ifndef MyFirstApp_Unit1H #define MyFirstApp_Unit1H //--------------------------------------------------------------------------- #include <System.Classes.hpp> #include <Vcl.Controls.hpp> #include <Vcl.StdCtrls.hpp> #include <Vcl.Forms.hpp> //--------------------------------------------------------------------------- class TForm1 : public TForm { __published: // IDE-managed Components TEdit *Edit1; TLabel *Label1; TMemo *Memo1; TButton *Button1; void __fastcall Button1Click(TObject *Sender); private: // User declarations public: // User declarations __fastcall TForm1(TComponent* Owner); }; //--------------------------------------------------------------------------- extern PACKAGE TForm1 *Form1; //--------------------------------------------------------------------------- #endif |
As ın this example, modern C++ applications have a GUI (Graphical User Interface) and they should be compatible with other operating systems (Windows, MacOS, iOS, Android). FireMonkey projects are multi Device (multi-platform) applications that you can compile and run on Windows, MacOS, iOS and Android .You can try recreating the example above with as a FireMonkey (FMX) application.
More beginner’s examples can be found in the Introduction section of https://learncplusplus.org/ and in Embarcadero DocWiki https://docwiki.embarcadero.com/ example links.
Get to know the basic features of Visual Studio C++ as well as the rich collection of String operations in this article.
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 new posts along with more examples and tutorials can be found at blogs.embarcadero.com and LearnCPlusPlus.org.
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition