From the blog

Embarcadero Welcomes Ian Barker to Developer Advocate Role

If you have watched any of Embarcadero’s online content, attended a RAD Studio webinar, or been to one of the in-person events you will most likely know the wonderful Jim McKeeth. Jim has been the Chief Developer Advocate and Engineer for Embarcadero since July 13th, 2013, just short of ten years. Today, however, the big news is that Jim is leaving Embarcadero and moving on to a new role as a developer advocate at EOS Network Foundation. Of course, we’re devastated that Jim’s particular brand of jovial code geekery will no longer be at the helm of the Developer Relations program, but we’re also thrilled for him to be moving on to new horizons and will get to stretch that burgeoning tech brain of his with the delights of such things as block-chain. Along with that news comes, of course, an announcement that Ian Barker (that’s me) will be taking over as Embarcadero Developer Advocate. I’ll be dealing with most of the things Jim did, those that are public, along with those which he did so capably behind the scenes too, of which there are many. Eli Mapstead will be expanding his role too and taking over some of the Python projects that Jim oversaw and championed. Yes, Jim can legitimately make the claim “it took two people to replace me“. Jim will become an Embarcadero MVP – once I’ve reviewed his application and decided if he’s good enough. ???? I’m going to do a more comprehensive retrospective blog post of some of the many great things Jim has been responsible for as well as highlight a few of his crazy professor moments, we have a thick stack of them – he’s a developer’s developer and irrepressible gadget freak – but, for now, we’re going to let the video do the talking. The audio echoed a little from time to time – but then it wouldn’t be the same if technology didn’t try to trip Jim or I up during recording, would it? From all of us in the Embarcadero and Idera family – thank you Jim. You’re a hard act to follow. Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder. Design. Code. Compile. Deploy. Start Free Trial   Upgrade Today    Free Delphi Community Edition   Free C++Builder Community Edition

Read More

How To Change Background Color Of An Edit In An FMX C++ App

C++ Builder is the easiest and fastest C++ IDE for building everything from simple to professional applications using visually amazing GUI controls and forms. Each form and component can be skinned with Styles which allow your application to have its own professionally designed attractive look and feel. The Style systems of the VCL and FMX (FireMonkey) award-winning frameworks is very easy to use but there is sometimes a learning curve to climb to understand how to get the best out of them. In this post, we explain how to change background color of an Edit (TEdit) which is one of the most frequently asked questions. These methods below, can be applied to other components too. How to change the background color of an Edit control using Styles? Styles are sets of graphical details that define the look and feel of an application visually. They are one of most beautiful and useful UI features of RAD Studio, that makes your UI elements ‘skinned’ with a professionally designed graphical look and feel. RAD Studio’s C++ Builder version comes with the award-winning VCL framework for high-performance native Windows apps (not wrapped in some kind of runtime interpretation layer) and the powerful FireMonkey (FMX) framework for cross-platform UIs. Both VCL and FMX apps support Styles. There are many different styles available, and they cater for almost every possible taste in aesthetics as well as providing dark and light mode versions. More details about Styles can be found here. You can also find additional Premium Styles here. If you want to learn how you can modernize your components with styles here is the post you need; Right-click on the Edit and select ‘Edit Custom Style…’ Expand Edit1Style: you’ll see the background node. Click on background to select it. Then add a TRectangle via the Palette. The IDE should expand the background node and show a new Rectangle1Style tied to the TRectangle, Via the Object Inspector change the Color of TRectangle Click on the Apply Style button in the ‘Style Designer’. Compile and run your application If you still have problems to set color, may be this docwiki can help you : https://blogs.embarcadero.com/edit-custom-style-to-change-the-background-color-of-a-fmx-tedit/ How to change background color of an Edit in C++ code? If you want to change the background color of a Edit component (TEdit) in C++ Builder, first you should set the StyleLookup property to “Editstyle” as below.   Edit1->StyleLookup = “Editstyle”;   If you look at the Custom Style of Edit, there is “background” property, so we should find this resource by using the FindStyleResource() method of Edit as given example below.   Edit1->StyleLookup = “Editstyle”; auto fmxobj = Edit1->FindStyleResource(“background”, false);   if this resource object found, we can create a rectangle (TRectangle) as a background as below.   std::unique_ptr rect(new TRectangle(fmxobj));   Here we used unique_ptr which more modern to create this rectangle. Now we can set properties of our Rectangle, including its color.   rect->Align = TAlignLayout::Client; rect->Fill->Color = color; rect->Stroke->Color = color; // = claNull; rect->HitTest = false; rect->SendToBack();   Now, at last we need to add this object by using .get() method of unique_ptr. And the final trick here is you must release this unique_ptr by using .release() otherwise it doesn’t have any effect.   fmxobj->AddObject(rect.get()); rect.release();   I asked one of Embarcadero’s engineers to explain this a little more to me and he noted that “If you insist on using unique_ptr, you must add a call to .release(); to tell the unique_ptr that you no longer want it to clean up […]

Read More

How To Use Gamepad Or Joystick Controller In A C++ Builder VCL App?

C++ is one of the most powerful programming languages that we can use to create games that are playable with mouse, keyboard and gamepads or joysticks. We use C++ not just in games but also in almost every kind of industry, in robotics, and in the control of IoT devices. Games frequently have better playability if the user can control the game with input devices other than keyboard. The most popular controllers for games are gamepads and joysticks. One of the simplest ways to use such game controller hardware on Windows is using the venerable XInput library. Despite XInput having been around for a long time it can still be used with the latest C++ IDE and compiler for Windows. In this post, we explain how you can use gamepad or joystick controller in C++ using with Xinput library. Is there a ready-made component for controlling a gamepad or joystick in C++ on Windows? If you are looking for a component library, there are Delphi and C++ Builder-compatible components built around the XInput library. The Controller library is a Delphi and C++ Builder component that allows applications to receive input from the Xbox Controller. The main features of this library are, Uses Windows XInput API. Available for Delphi/C++ Builder 6 – 11 and Lazarus 2.0.12 Source code included in the registered version. Royalty free distribution. You can download the trial version of the XInput library, or you can buy a professional edition from here. How can I control a gamepad or joystick in C++ with the Xinput Library? XInput library was developed quite some time ago and is a deprecated but still supported library by Microsoft. They recommend moving towards the GameInput library or Windows.Game.Input for Windows applications. If we look at these kinds of libraries (i.e GamePad.h library), like MS’ own DirectXTK, we can see that the toolkit allows one to define USING_XINPUT vs. USING_GAMEINPUT vs. USING_WINDOWS_GAMING_INPUT to pick which underlying library is used. If we compare  XInput compared to GameInput: XInput library is easy to implement Windows applications. XInput library is limited to 4 controllers. XInput library has no uniform interface to other input (like mouse/keyboard). XInput library occurs with higher latency. XInput library is not friendly with other controllers. i.e. no support for Xbox One Rumble Motors. In brief, DirectInput is better than XInput. If you still want to use XInput, you can check more about https://learn.microsoft.com/en-us/windows/win32/xinput/getting-started-with-xinput XINPUT_GAMEPAD structure (declared in ) is explained here: https://learn.microsoft.com/en-us/windows/win32/api/xinput/ns-xinput-xinput_gamepad In there, this structure has these members: wButtons, bLeftTrigger, bRightTrigger, sThumbLX, sThumbLY, sThumbRX, sThumbRY. Here wButtons member is used as a bitmask of the device digital buttons, it can be used as below. wButtons Device digital button flags Gamepad Bitmask XINPUT_GAMEPAD_DPAD_UP 0x0001 XINPUT_GAMEPAD_DPAD_DOWN 0x0002 XINPUT_GAMEPAD_DPAD_LEFT 0x0004 XINPUT_GAMEPAD_DPAD_RIGHT 0x0008 XINPUT_GAMEPAD_START 0x0010 XINPUT_GAMEPAD_BACK 0x0020 XINPUT_GAMEPAD_LEFT_THUMB 0x0040 XINPUT_GAMEPAD_RIGHT_THUMB 0x0080 XINPUT_GAMEPAD_LEFT_SHOULDER 0x0100 XINPUT_GAMEPAD_RIGHT_SHOULDER 0x0200 XINPUT_GAMEPAD_A 0x1000 XINPUT_GAMEPAD_B 0x2000 XINPUT_GAMEPAD_X 0x4000 XINPUT_GAMEPAD_Y 0x8000 How to use a gamepad or joystick in C++ Builder VCL Application? Here are the step to use gamepad or joystick in C++ Builder VCL app, Create a new VCL Windows application in C++ Builder. Drag a Timer (TTimer) component onto the Form. In the Object Inspector window, set its interval to 15 and be sure it is enabled. Drag a Shape (TShape) component on to Form. In Object Inspector window, set its Shape property to stCircle, change Brush color something that makes you happy. Double click to […]

Read More

What’s New for Makefile Tools in VS Code Version 0.7.0 – Variable Expansion and more…

The Makefile Tools team in VS Code has shipped the latest 0.7.0 version of the extension. In this version, we have enabled variable expansion for your Makefile projects in settings, so you no longer need to write plain paths for your Makefiles in the settings.json for the extension and can instead utilize variables that the Makefile extension can detect and replace values for. This allows for easier sharing of settings.json and improved consistency. Also, this allows for parameterization, so that you can define one setting and don’t need to constantly change its value if you toggle between different configurations and/or build targets.  We have also improved the user experience for when Makefile, Make and build.log are not found and added new support for C++23. The details of all that is new with this release can be found here in this change log.  Variable Expansion The macros that are now supported to work from any setting entry-point are:  ${workspaceFolder} and  ${workspaceRoot} ${workspaceFolderBasename}  ${userHome}  ${env:ENVIRONMENT_VARIABLE}  ${config:ANY_EXTENSION_SCOPE.ANY_SETTING_ID}  ${command:ANY_EXTENSION_SCOPE.ANY_COMMAND_ID}  ${configuration} and  ${command:makefile.getConfiguration} ${buildTarget} and  ${command:makefile.getBuildTarget} You can use this syntax in your settings.json, and the Makefile extension will automatically detect and populate the relevant information for these variables. Below are a few examples of using these macros to substitute your existing plain text. Variable Example Expanded Variable Example “makefile.extensionOutputFolder”: “${userHome}/MyOutput/${workspaceFolderBasename}”  C:/Users/Public/MyOutput/MyProject  “makefile.makePath”: “${env:ProgramFiles(x86)}/GnuWin32/bin/make.exe”  C:/Program Files (x86)/GnuWin32/bin/make.exe  “makefile.extensionLog”: “extension_${configuration}_${buildTarget}.log”  extension_debug_x86.log   “makefile.configurationCachePath”: “cache_${command:makefile.getConfiguration}_${command:makefile.getBuildTarget}.log”  cache_debug_x86.log   “makefile.compileCommandsPath”: “${config:C_Cpp.default.compileCommands}”  C:/github/projects/MyProject/build/compile_commands.json  “makefile.makefilePath”: “${workspaceFolder}/Makefiles/makefile.in”  C:/github/projects/MyProject/Makefiles/makefile.in  “makefile.launchConfigurations”:{[…        “binaryPath”: “${workspaceRoot}/test.exe”,       “binaryArgs”: [\${buildTarget}, “${buildTarget}”]  …]}  test.exe ${buildTarget} x86 Improved messaging when Makefile, Make and Build.log are not found  Now, you can see the status of all critical components used in activating the extension in the left–side Makefile Tools project outline including the newly added Makefile, Make, and Build Log. Makefile, Make, and Build.log are not found, the extension has a “not found” status integrated into this side panel next to each item.   in the latest pre-release version, you can specify the path to these files so that the extension can find them and activate all capabilities fully as well as show the current status of the project. Once you select a path for each item, you can view the active path and status in the side panel.  We have also set up a pre-release pipeline, so you can get earlier access before an official release ship to any bug fixes and releases that users merge to the Makefile Tools repository. All you need to do is click the “Switch to Pre-Release version” under the Makefile Tools extension.  Some new functionality is available in the latest pre-release, including the ability to open Makefile and Build Log using new buttons in the project outline.  Future Work Next, we will be investigating some of your most highly up-support for multi-root repositories.  What do you think? Download the Makefile Tools extension for Visual Studio Code today, give the latest version a try, and let us know what you think. Check out our README documentation to learn more about activating the extension and getting started.  If you run into any issues, or have any suggestions, please report them in the Issues section of our GitHub repository.  We can be reached via the comments below or in email at VisualC@microsoft.com. You can also find our team on Twitter at  @VisualC. 

Read More

My Next Mentoring Program: “C++20: Get the Details”

Tweet Contents[Show] C++20: Get the Details: 16 Stations Mentoring Programs Competency Levels More Information?   Modern C++ Mentoring, My next mentoring program, “C++20: Get the Details”, starts in July. Registration will open in June.   Here is more information about my third mentoring program. C++20: Get the Details: The mentoring program consists of 16 stations. You have to invest at least 3 hours per week for each one. This means the program takes four months, and you can integrate my program into your workday. 16 Stations Introduction History C++ Compiler Standard Support Preparation Concepts Motivation Usage Placeholders Abbreviated Function Templates Concepts Predefined Concepts Definition of Concepts Requires Expressions User-Defined Concepts An Evolution or a Revolution Comparison Equality Comparison The Three-Way Comparison Operator Safe Comparison of Integers Constness consteval constinit std::is_constant_evaluated constexpr Containers and Algorithms Further Core Language Improvements Designated Initialization Templates Lambdas The Ranges Library Ranges and Views Characteristics Range Adaptors Comparison of std and std::ranges Algorithms Modules Advantages Module Interface Unit and Module Implementation Unit Submodules and Module Partitions Guidelines std::span and New Container Functions std::span Unified Deletion of Elements Uniform Checking of Elements String: starts_with and ends_with Formatting Library Overview Format String User-Defined Types Calendar and Time Zones Basic Types Time of Day Calendar Dates Time Zones Standard Library Utilities Mathematical Constants Midpoint and Linear Interpolation Bit Manipulation std::source_location Coroutines Characteristics The Framework Awaitables and Awaiters The Workflows Atomics std::atomic_flag std::atomic std::atomic_ref Synchronization and Coordination Latches and Barriers Semaphores Synchronized Output Streams Cooperative Interruption std::jthread  std::condition_variable_any std::stop_source, std::stop_token, and std::stop_callback C++20 is my third mentoring program. Here is more information about this program, “C++20: Get the Details” and more information about my mentoring programs: modernescpp.org. The following ones are open or will open in the next two years. Mentoring Programs October 2022: “Fundamentals for C++ Professionals” is open May 2023: “Design Patterns and Architectural Patterns with C++” is open July 2023: “C++20: Get the Details” will open (registration open in June) January 2023 – January 2025: The remaining mentoring programs are open for registration. I publish a new mentoring program each half a year. Here are the upcoming mentoring programs in the next two and a half years. Clean Code: Best Practices for Modern C++ Generic Programming (Templates) with C++ Concurrency with Modern C++ HPC with Modern C++   All mentoring programs are based on my books, classes, presentations, and posts. The mentoring programs have three different competency levels. Competency Levels   The competency levels of the mentoring programs are beginner, intermediate, and advanced. Beginner Fundamentals for C++ Professionals Intermediate Design Patterns and Architectural Patterns with C++ Clean Code: Best Practices for Modern C++ C++20: A Deep Insight Advanced Generic Programming (Templates) with C++ Concurrency with Modern C++ HPC with Modern C++ To master the intermediate or advanced mentoring programs, you must master the beginner mentoring program “Fundamentals for C++ Professionals” or any similar content. If you want to know more about the running mentoring programs “Fundamentals for C++ Professionals” or “Design Pattern and Architectural Pattern with C++“, follow the links. More Information? I host my mentoring program on modernescpp.org. I’m happy to answer your question:  This email address is being protected from spambots. You need JavaScript enabled to view it.. If you want to stay informed, subscribe here: https://bit.ly/ModernesCppMentorings     Modern C++ Mentoring,       […]

Read More

Dealing with Mutation: Locking

Tweet Contents[Show] Scoped Locking Strategized Locking Run-Time Polymorphism Compile-Time Polymorphism What’s Next? Locking is a classical way to protect a shared, mutable state. Today, I will present the two variants, Scoped Locking and Strategized Locking. Locking is a straightforward idea to protect a critical section. A critical section is a section of code that, at most, one thread can use at any time. Scoped Locking Scoped locking is the idea of RAII applied to a mutex. Scoped locking is also known as synchronized block and guard. The key idea of this idiom is to bind the resource acquisition and release to an object’s lifetime. As the name suggests, the lifetime of the object is scoped. Scoped means that the C++ run time is responsible for object destruction and, therefore, for releasing the resource. The class ScopedLock implements Scoped Locking. // scopedLock.cpp #include #include #include #include class ScopedLock{ private: std::mutex& mut; public: explicit ScopedLock(std::mutex& m): mut(m){ // (1) mut.lock(); // (2) std::cout

Read More

How To Change The Background Color Of A Memo In An FMX C++ App

C++ Builder is the easiest and fastest C++ IDE for building professional FMX C++ Apps with powerful GUI components like Memo, Edit, ListBox, StringGrid, and many more. Each component can be skinned with Styles to change their visual appearance. Styles are very powerful and because of this it can sometimes take a little to get used to how they work. In this post, we explain how to change the background color of a Memo (TMemo), one of the most frequently asked questions about using styles. These methods below can be applied to other components too. How to change the background color of a Memo in C++ Builder by using Styles? Styles are sets of graphical details that define the look and feel of an application. They are one of the most beautiful and useful UI features of RAD Studio that can really add some extra professionalism to your apps. RAD Studio’s C++ Builder version comes with the award-winning VCL framework for high-performance native Windows apps (not wrapped in some kind of runtime interpretation layer) and the powerful FireMonkey (FMX) framework for cross-platform UIs. Both VCL and FMX C++ Apps support Styles. There are many styles in C++ Builder, and RAD Studio. More details about Styles can be found here. You can also find Premium Styles here. If you want to learn how you can modernize your components with styles this post has some great details; What are the steps to change the background color of a Memo in C++ Builder by using Styles? 1. Right-click on the Memo and select ‘Edit Custom Style…’ 2. Expand Memo1Style: you’ll see the background node. Click on background to select it. Then add a TRectangle via the Palette. The IDE should expand the background node and show a new Rectangle1Style tied to the TRectangle, 3. Via the Object Inspector change the Color of TRectangle as below 4. Click on the Apply Style button in the ‘Style Designer’, Save All. 5. Compile and run your application If you still have problems setting the color, this DocWiki article can help you: https://blogs.embarcadero.com/edit-custom-style-to-change-the-background-color-of-a-fmx-tedit/ How to change the background color of a Memo in C++ Builder code? If you want to change the background color of a Memo component (TMemo) in C++ Builder, first you should set the StyleLookup to “Memostyle” as shown below: Memo1->StyleLookup = “Memostyle”; If you look at the Custom Style of Memo, There is a “background” property, so we should find this resource by using FindStyleResource() method of Memo as given in the example below: Memo1->StyleLookup = “Memostyle”; auto fmxobj = Edit1->FindStyleResource(“background”, false); If this resource object we can create a rectangle (TRectangle) as a background: std::unique_ptr<TRectangle> rect(new TRectangle(fmxobj)); Here we used unique_ptr which more modern to create this rectangle. Now we can set properties of our Rectangle, including its color. rect->Align = TAlignLayout::Client; rect->Fill->Color = color; rect->Stroke->Color = color; // = claNull; rect->HitTest = false; rect->SendToBack(); Now, at last we need to add this object by using the .get() method of unique_ptr. And the final trick here is you must release this unique_ptr by using .release() otherwise it doesn’t have any effect. fmxobj->AddObject(rect.get()); rect.release(); Is there a full example of how to change the background color of a Memo in C++ Builder code? Here is a full C++ Builder FMX FMX C++ Apps example that changes the color of 3 TMemo components that has Memo1, Memo2, Memo3 names. To do this we create a ChangeMemoColor() function that uses the […]

Read More

How To Use A Game Pad Or Joystick Controller In C++ On Windows

C++ On Windows is one of the most powerful programming languages that we use for all sorts of purposes, from regular applications, games, business, industrial infrastructure, robotics, and in the control of IoT devices. The most well-known controllers for those areas where human and computer interaction are important and stretches beyond simple keyboard input are joysticks or gamepads. One of the simplest examples to use them on Windows is using the venerable XInput library which has been around for quite a long time but can still be easily used with the latest C++ Compiler. In this post, we explain how you can use a gamepad or joystick controller in C++ On Windows with Xinput library. Is there a component for the gamepad or joystick in C++ On Windows? If you are looking for a ready-to-use component library, there are Delphi and C++ Builder-compatible components built on the XInput library. For example, the Controller library is a Delphi and C++ Builder component that allows applications to receive input from an Xbox Controller. The main features of this library are, Uses Windows XInput API. Available for Delphi/C++ Builder 6 – 11 and Lazarus 2.0.12. Source code included in the registered version. Royalty free distribution. You can download the trial version of the XInput library or you can buy a professional edition from Winsoft.sk. How can I control a gamepad or joystick in C++ with the Xinput Library? The XInput library is deprecated but it still supported by Microsoft. They recommend moving towards the GameInput library or Windows.Game.Input for Windows applications. If we look at these kinds of libraries (i.e GamePad.h library), like MS’ own DirectXTK, we can see that the toolkit allows one to define USING_XINPUT vs. USING_GAMEINPUT vs. USING_WINDOWS_GAMING_INPUT to pick which underlying library is used. If we compare  XInput compared to GameInput: XInput library is fairly old and easy to implement Windows applications. XInput library is limited to 4 controllers. XInput library has no uniform interface to other inputs (like mouse/keyboard). XInput library input occurs with higher latency. XInput library is not friendly with other controllers. i.e. no support for Xbox One Rumble Motors. So, briefly, DirectInput is a better long-term choice than XInput. If you still want to use XInput, you can read more about https://learn.microsoft.com/en-us/windows/win32/xinput/getting-started-with-xinput XINPUT_GAMEPAD structure (declared in ) is explained here : https://learn.microsoft.com/en-us/windows/win32/api/xinput/ns-xinput-xinput_gamepad As in there, this structure has these members: wButtons, bLeftTrigger, bRightTrigger, sThumbLX, sThumbLY, sThumbRX, sThumbRY. Here wButtons member is used as a bitmask of the device digital buttons, it can be used as below, wButtons Device digital button flags Gamepad Bitmask XINPUT_GAMEPAD_DPAD_UP 0x0001 XINPUT_GAMEPAD_DPAD_DOWN 0x0002 XINPUT_GAMEPAD_DPAD_LEFT 0x0004 XINPUT_GAMEPAD_DPAD_RIGHT 0x0008 XINPUT_GAMEPAD_START 0x0010 XINPUT_GAMEPAD_BACK 0x0020 XINPUT_GAMEPAD_LEFT_THUMB 0x0040 XINPUT_GAMEPAD_RIGHT_THUMB 0x0080 XINPUT_GAMEPAD_LEFT_SHOULDER 0x0100 XINPUT_GAMEPAD_RIGHT_SHOULDER 0x0200 XINPUT_GAMEPAD_A 0x1000 XINPUT_GAMEPAD_B 0x2000 XINPUT_GAMEPAD_X 0x4000 XINPUT_GAMEPAD_Y 0x8000 How to use a gamepad or joystick in C++? If you wonder how XInput library works, you can create a simple example as in given steps below. First, we need library header to use XInput library. This is how you can use XInput library in C++. #include #include #include #pragma comment(lib, “XInput.lib”) Now, lets create a TController class that have n for the controller number and state for it. Here is an example. class TController { private: int n; XINPUT_STATE state; public:             // add controller methods here }; Then we need to add some methods for this class, first lets set our private controller number n in construction like […]

Read More

Advantages and Disadvantages of The C++ Programming Language

In the last 40 years C++ has earned, and maintained, a reputation as one of the most efficient programming languages. C++ is still hugely popular, often in the top 3 of any lists of popular programming languages and is used widely across a wide array of operating systems. Choosing the right programming language and IDE (we call them C++ tools) are very important in the early stages of learning to program. Generally, new developers want to know the advantages and disadvantages of the C++ programming language, and in this post, we try to explain its pros and cons for you. What are the pros and cons of C++ programming language? What are the advantages of C++? 1. C++ is compiler-based with very fast execution times C++ is a compiler-based programming language and that helps make it the fastest and one of the most powerful programming languages. This is one of the reasons to use hardware and software algorithms efficiently. In general, there are two types of programming languages: Interpreted and Non-Interpreted (Compiled). All computers work with something called machine code (code that can be directly executed by the computer’s CPU) that tells the computer what to do. This is the most native and fastest code, but it requires writing many lines for even quite simple things and is hard to generalize for all kinds of machines. It’s also not very easy to understand for humans. A compiler (C or C++ Compiler, etc.) is a computer program that converts a program written in a ‘high level’ programming language such as C++ code into executable machine code. The high-level language looks more like English and is much easier to understand and less complicated. 2. C++ is a structured and object oriented programming language C++ allows developers to use C language which is a structured programming language and it also allows Object Oriented Programming. Object Oriented Programming (OOP) is a way to integrate with objects which can contain data in the form of attributes or properties of objects, and code blocks in the form of methods, and functions of objects. These attributes and methods that belong to the class are generally referred to as class members. Object-Oriented Programming is a good way to work on data and work with functions in memory. Classes and Objects are the best way to work on properties and functions. Object-Oriented Programming has many advantages over procedural programming and it is the most characteristic feature of the visual and modern C++ programming language. 3. C++ supports visual 2D, 3D and GUI-based programming C++ is useful to make GUI-based applications on Windows, iOS, Android, Mac OS, Linux, and many other less popular OSes. C++ has different GUI frameworks i.e. VCL, FMX, GTK, and other Visual components. Modern C++ has been enhanced with Visual Bindings, High-DPI 4K supports, responsive features, skinned UI elements, glamorous one-click GUI sets, 2D and 3D components like OpenGL, Skia, and Viewport3D; and has many game engines like Unreal Engine, Unity, O3DE. C++ is also useful to develop graphical 2D and 3D applications, real-time computational simulations, and analysis, C++ highly uses CPU and GPU-based applications with graphical supports like Physics, OpenCL, Vulkan, HPC, etc. 4. C++ is a mid-level programming language with low-level capabilities Because of its capability in assembly-level coding and compiling abilities, I prefer calling C a ‘close to low-level language’. Briefly, we may say C and C++ languages are close […]

Read More

How To Use Base-8 (Octal) Numbers In Modern C++?

In general, in nearly all programming languages, including Modern C++, we use base-10 numbers, while our computer hardware uses the binary base-2 system (bits). I personally believe that base-10 is because we typically have 10 fingers and since we learn to counting on our fingers we use base-10 primarily. However, due to the way binary works it is sometimes convenient to use base-8 system octal (oct) and base-16 system hexadecimal (hex) numbers in programming. In this post, we explain how to use Base-8 octal numbers in Modern C++. What is the octal number system? The octal – or oct – number system is the base-8 system, Octal uses the digits from 0 to 7. In general, we use a base-10 number system in normal life. In the digital world we also use base-2, base-8, and base-16 as well as base-10. If you want to explore the different numbering systems, try this Wikipedia article. Let’s give some octal examples and their values in the decimal system, 1octal  = 1 10octal  = 8 100octal = 64 How to declare base-8 (octal) number in modern C++? In C++, when we use octal numbers in C++ code, we put 0 on the left side of an octal number. This zero shows it is an octal representation. int x; // 015 in octal is 13 base10 or decimal x = 015; How to initialize base-8 (octal) number in modern C++? here the first zero on the left side of 0010 defines this number representation is an octal representation. The integer x value is results as 8; How to set an integer to base-8 (octal) number in modern C++? We can use std::istringstream() which is declared in library. Here Octal number “010” is declared into x as a octal number, now when you print this variable, it will be displayed in octal decimal system,    int x;    std::istringstream(“010”) >> std::oct >> x;    std::cout << x << std::endl; How to print out base-8 (octal) number in modern C++? When we print out base-8 (octal) numbers we use std::oct format as below, int x = 0010; std::cout << std::oct << x << std::endl; How to print out base-8 (octal) number in C language? C has very powerful printf() function and there is a ‘%o‘ Format Specifier to print out octal numbers. How to display base-8 (octal) number in C++ Builder? C++ Builder is using UnicodeString in most of components, and UnicodeString very powerful printf() method. There is a ‘%o‘ Format Specifier to print out octal numbers that can be used as below, int i = 64; // decimal UnicodeString ustr; ustr.printf(“%o n”, i); Edit1->Text = ustr; How to convert base-8 (octal) number to (base-10) decimal number in modern C++? When you declare an integer with octal representation, it is automatically converted to base-10 number. For example: here a = 8 in the decimal system. there is another method std::stoi that converts octal representation in string to an integer. Here is an example, int x = std::stoi(“011”, 0, 8); std::cout << x << std::endl; How to convert (base-10) decimal number to base-8 (octal) number in modern C++? In C++, computation is done in base-2 while you have a decimal number. If you want to convert base-10 decimal number to base-8 octal number, you only need to convert to a octal number or string when you […]

Read More