Programming dev-c++ end FireMonkey FMX ide learn learn

What Are Declared True Constants In Modern C++?

C++ has many different variable types to develop modern applications with modern C++ IDE‘s and compilers. Several different language constructs are referred to as ‘constants’. There are numeric constants and string constants. Every enumerated type defines constants that represent the values of that type. Declared constants are either true constants or typed constants. In this post, we will explain what we mean by a declared constant and what is a true constant which is a kind of declared constant in C++. What are declared constants in Modern C++? Several different language constructions are referred to as ‘constants’. There are numeric constants (also called numerals) like 17, and string constants (also called character strings or string literals) like ‘Hello world!’. Every enumerated type defines constants that represent the values of that type. There are predefined constants like True, False, and nil. Finally, there are constants that, like variables, are created individually by declaration. Declared constants are either true constants or typed constants. There are predefined constants like True, False, and nil. Finally, there are constants that, like variables, are created individually by declaration. These two kinds of constant are superficially similar, but they are governed by different rules and used for different purposes. What are true constants in Modern C++? A true constant is a declared identifier whose value cannot change. The syntax for declaring a true constant is: const identifier = constantExpression; For example: declares a constant called MaxValue that returns the integer 237. Where identifier is any valid identifier and constantExpression is an expression that the compiler can evaluate without executing your program. If constantExpression returns an ordinal value, you can specify the type of the declared constant using a value typecast. For example: const MyNumber = Int64(17); declares a constant called MyNumber, of type Int64, that returns the integer 17. Otherwise, the type of the declared constant is the type of the constantExpression. If constantExpression is a character string, the declared constant is compatible with any string type. If the character string is of length 1, it is also compatible with any character type. If constantExpression is a real, its type is Extended. If it is an integer, its type is given by the table below. Types for integer constants Range of constant (hexadecimal) Range of constant (decimal) Type Aliases 0 $FF 0 255 Byte UInt8 0 $FFFF 0 65535 Word UInt16 0 $FFFFFFFF 0 4294967295 Cardinal UInt32, FixedUInt 0 $FFFFFFFFFFFFFFFF 0 18446744073709551615 UInt64 -$80 $7F -128 127 ShortInt Int8 -$8000 $7FFF -32768 32767 SmallInt Int16 -$80000000 $7FFFFFFF -2147483648 2147483647 Integer Int32, FixedInt -$8000000000000000 $7FFFFFFFFFFFFFFF -9223372036854775808 9223372036854775807 Int64 32-bit native integer type Range of constant (hexadecimal) Range of constant (decimal) Type Equivalent type -$80000000 $7FFFFFFF -2147483648 2147483647 NativeInt Integer 0 $FFFFFFFF 0 4294967295 NativeUInt Cardinal 64-bit native integer type Range of constant (hexadecimal) Range of constant (decimal) Type Equivalent type -$8000000000000000 $7FFFFFFFFFFFFFFF -9223372036854775808 9223372036854775807 NativeInt Int64 0 $FFFFFFFFFFFFFFFF 0 18446744073709551615 NativeUInt UInt64 32-bit platforms and 64-bit Windows integer type 32-bit platforms include 32-bit Windows and Android. Range of constant (hexadecimal) Range of constant (decimal) Type Equivalent type -$80000000 $7FFFFFFF -2147483648 2147483647 LongInt Integer 0 $FFFFFFFF 0 4294967295 LongWord Cardinal 64-bit platforms integer type excluding 64-bit Windows 64-bit platforms include 64-bit iOS, 64-bit Android, 64-bit macOS and 64-bit Linux. Range of constant (hexadecimal) Range of constant (decimal) Type Equivalent type -$8000000000000000 $7FFFFFFFFFFFFFFF -9223372036854775808 9223372036854775807 LongInt Int64 0 $FFFFFFFFFFFFFFFF 0 18446744073709551615 LongWord UInt64 Here are some examples of constant declarations: 1 2 3 4 5 6 7 8 […]

Read More

How To Run A C Or C++ Program On iOS

A fast and reliable C and C++ Compiler and IDE for app development software for iOS is very important for beginners and professionals alike, whether they are developing C++ for iOS or for any of the other operating systems and targets. The C and C++ programming languages are subjectively the World’s most powerful programming languages and consistently appear in the World’s top three most popular programming languages. Thanks to its huge range of ready-made variables, functions, methods, namespaces and libraries it’s the do-everything toolkit which can be used for everything from regular simple apps to low-level operating system drivers, IoT hardware control and everything in between. When a user wants to develop modern C++ applications, she or he will benefit from investing a very small amount of time in becoming familiar with the functions, features and shortcuts of a professional IDE. A small effort in that area pays dividends in productivity. In this post we explain basic of using C++ Builder to create an iOS app as a guide for beginners. What is a good IDE for creating a C++ program for iOS? Do you know that you can develop C/C++ iOS Apps on Windows 11 with the latest RAD Studio / C++ Builder? C++ Builder supports all C commands and CLANG LLVM, C++ 17 standards. RAD Studio with C++ Builder and Delphi is a great IDE and compiler running on Windows that supports multi-device applications for different platforms including iOS and you can develop native ARM applications for M1 Silicon CPUs used in the latest Apple hardware too. So, your application’s program code can be recompiled so that it runs on everything from the latest Windows 11 version as well as on Apple ‘desktop’ devices such as the MacBook laptops, Mac Minis and iMacs using either Intel processors or the new M1 ‘Silicon’ CPUs. Yet that same program code can almost entirely be reused with little or no changes so it may be compiled for iOS where your apps can run on the very latest iPhone devices. Everywhere your users are, your C++ and Delphi apps can be. In my opinion, because of its multi-device application and great tools of IDE, C++ Builder is the best C++ IDE Software and the best CLANG-based compiler that supports multi-device applications for all your needs including professional iOS application. How to create and run a C++ Program for iOS with the RAD Studio IDE and C++ Builder? C++ Builder is the easiest and fastest C and C++ IDE for building simple or professional applications on the Windows, macOS, and iOS 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. 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. There is a free C++ Builder Community Edition for students, beginners, and startups. More details about C++ Builder & RAD Studio for the beginners can be found in Official Wiki of Rad Studio. You can download the free C++ Builder Community Edition here: https://d-data.ro/product/c-builder-in-romania//starter.Professional developers can use the Professional, Architect or Enterprise versions of C++ Builder. Please visit https://d-data.ro/product/c-builder-in-romania/. See What’s New in RAD Studio 11 Download […]

Read More

What Is Defaulted Function or Method In Modern C++ Now?

Modern C++ is really amazing with a lot of great features of programming. One of the features of Modern C++ is a Defaulted Function or in another term Defaulted Method of classes that is a function that contains =default; in its prototype. Defaulted functions are a feature of C++11 and above. In this post, we explain what is a defaulted function or method in modern C++. What is defaulted function or method in Modern C++? A defaulted function (actually defaulted method, they are functions in classes) is a function that contains =default; in its prototype. This construction indicates that the function’s default definition should be used. Defaulted functions are a C++11 specific feature. If you have a method (including construction method) and you want to make it defaulted method, just add ‘=default;’ specifier to the end of this method declaration to declare that method as an explicitly defaulted method (or explicitly defaulted function). Is there a simple example of a defaulted function or method in modern C++? Here is an example to demonstrates defaulted function:  class Tmyclass {         Tmyclass() = default;                    // OK }; This will allow the compiler generate the default implementations for explicitly defaulted methods which are more efficient than manually programmed method implementations.  Here is another example class. class A {         A() = default;                    // OK         A& operator = (A & a) = default;  // OK         void f() = default;               // ill-formed, only special member function may default }; What is defaulted function or method in Modern C++? For example, if we have a parameterized constructor, we can use the ‘=default;’ specifier in order to create a default method. Because the compiler will not create a default constructor without this. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 #include   class Tmy_class { public:   Tmy_class(int x) // parameterized constructor { std::cout

Read More

How To Use C++ Standards In C++ Compiler Options

C++ is a very decent programming language that has a very strong compiler supported by a big community on a range of different platforms. The C++ language definitions, syntax, and functionality are organized into different standards. Those standards are usually named after the year the standard was adopted such as 1998 for C++98, 2011 for4 C++11, 2014 for C++14, and 2017 for C++17. One of the great features of a C++ compiler is you can choose which standards you want your code to be compiled against, before the compilation of your source code. This allows the compiler to check that your code complies with that standard. In this post, we explain what the standards are, how you can view them, how you can check the compatibility of your C++ source code against different standards, and how you can choose to use C++ standards in C++ compiler options. What is a C++ standard? Standards are an international agreement for C++ compilers, made by the IDE and compiler developers of different operating systems (Embarcadero C++ Builder, Microsoft MSVC, GNU GCC, Apple Swift, etc.). They are formal, legal, and very high-level detailed technical documents intended primarily for people writing C++ compilers and standard library implementations.  The current available standards and some of their key features are listed below. How to use C++ standards in C++ compiler options? When we use ‘-std=’ option in a C++ compiler this option type enables or disables some features. We need to use these features to see the effect of each C++ standard option. Personally, I always prefer to use the latest version of the standards in my compilers. However, when programming, sometimes you may have to work on old or legacy C++ source, or you may be programming to another company that uses older standard compilers. Or maybe you just want to check if your code is compatible with a particular standard, or the code uses new standards. At these times, you can use std option in C++ compilers. In general, we can use the -std option to compile to a particular C++ standard. Here are some option examples, -std=c++98 -std=c++11 -std=c++14 -std=c++17 -std=c++20 or -std=c++2a For example, if you want to compile your code with C++11 features, you can use C++ Builder 64bits command line compiler as shown below: bcc64 –std=c++11 myapp.cpp –o myapp For an example, we can write this C++ code below which uses a feature found in the C++17 standard and above. int main() {   static_assert(sizeof(int)==4); // C++17 feature     return 0; } If you are using the C++17 compiler, this code will be compiled successfully because the static_assert feature comes with C++17. If you compile this code with -std=c++11 or -std=c++14 options this time you will get warning which is telling you that you have requested C++ standard version 11, but there is a feature that requires C++ standard version 17 (Until C++17, a message was required w/ static_assert). How to use C++ standards in the C++ Builder compiler options? In C++ Builder CLANG compiler, we can use -std option to compile in previous standards. This option can be used in bcc32c and bcc64, both support these std options below, -std=c++11 -std=c++14 -std=c++17 I should note that, C++11 and C++14 options are partially supported, these options do not have a STL that works with all, so you have the latest STL one for C++17. According […]

Read More

Learn Unicode Character Types and Literals in Modern C++

C++11 brings a lot of improvements and I think one of the most important features were the Unicode Character Types and Literals that allow more support for strings in different languages globally. C++11 introduced a new character type to manipulate Unicode character strings. This can be used in C++11, C++14, C++17, and above. This feature improved interactions in next generation C++ applications, like chat, social media applications, and so on by allowing a more diverse set of language characters and symbols to be displayed as well as emoticons. In this post, we explain what are Unicode character types and literals in Modern C++. What are Unicode character types and literals in Modern C++ 11? Unicode character types and literals allow more support for different languages, characters, and symbols in strings. C++11 introduces new character types to manipulate Unicode character strings. These can be used in C++11, C++14, C++17, and above. This feature improved language support in editor and design applications (i.e. RAD Studio uses Unicode Strings). It also vastly improved interactions in the next generation C++ applications like chat and social media. This is why we can display smiley faces ????, Vulcan hand signals ???? and love hearts ????. C++ Builder implements new character types and character literals for Unicode. These types are among the C++11 features added to bcc32, bcc32c, and bcc64 compilers. 1. New character types C++11 introduces new character types to manipulate Unicode character strings. For more information on this feature, see Unicode Character Types and Literals (C++11). 2. Unicode string literals C++11 introduces new character types to manipulate Unicode string literals. For more information on this feature, see Unicode Character Types and Literals (C++11). 3. Raw string literals 4. Universal character names in literals In order to make the C++ code less platform-dependent, C++11 lifts the prohibitions regarding control and basic source universal character names within character and string literals. Prohibitions against surrogate values in all universal character names are added. For more information on this feature, see Universal character names in literals Proposal document. 5. User-defined literals C++11 introduces new forms of literals using modified syntax and semantics in order to provide user-defined literals. Using user-defined literals, user-defined classes can provide new literal syntax. For more information on this feature, see User-defined literals Proposal document. What are the Unicode character types char16_t and char32_t in Modern C++? With the C++11 standards, two new types were introduced to represent Unicode characters: char16_t is a 16-bit character type. char16_t is a C++ keyword. This type can be used for UTF-16 characters. char32_t is a 32-bit character type. char32_t is a C++ keyword. This type can be used for UTF-32 characters. The existing wchar_t type is a type for a wide character in the execution wide-character set. A wchar_t wide-character literal begins with an uppercase L (such as L’c’). We have a very good post that explains how you can use character literals in modern C++. What are the character literals u’character’ and U’character’ in Modern C++? There are two new ways to create character literals of the new types: u’character’ is a literal for a single char16_t character, such as u’g’. A multicharacter literal such as u’kh’ is badly formed. The value of a char16_t literal is equal to its ISO 10646 code point value, provided that the code point is representable as a 16-bit value. Only characters in the basic multilingual plane (BMP) can be represented. U’character’ is a literal for a single char32_t character, such as U’t’. A multicharacter literal such as U’de’ is ill-formed. […]

Read More

What Is The ‘>>’ Right-Angle Bracket Support In C++?

C++11 brings a lot of improvements over C++98. In C++98, two consecutive right-angle brackets (>>) give an error, and these constructions are treated according to the C++11 standard which means CLANG compilers no longer generate an error about right angle brackets. In this post, we explain this and how to solve the right-angle bracket problem in C++. What is the right-angle bracket problem in C++? Ever since the introduction of angle brackets in C++98, C++ developers have been surprised by the fact that two consecutive right-angle brackets must be separated by whitespace. For example, if you declare two-dimensional vector (int and bool) as below: #include   typedef std::vector vec1;  // OK   typedef std::vector vec2;  // Error In C++98, the first declaration is OK, but the second declaration give errors because of ‘>>‘ (right angle brackets). However, both are OK in C++11 and above. One of the problems was an immediate consequence of the “maximum munch” principle and the fact that >> is a valid token (right shift) in C++. In the CLANG-enhanced C++ compilers, two consecutive right-angle brackets no longer generate an error, and these constructions are treated according to the C++11 standard. This issue was a minor issue in C++98, but persisting, annoying, and somewhat embarrassing problem. The cost was reasonable, and it seems therefore worthwhile to eliminate the surprise. C++98 developers needed to add space between them. If you want to get more information, you can see details here. How can I solve the right-angle bracket problem in C++? If you have C++98 compiler and come across the right-angle bracket problem, you need to add space between two ‘>’ right angle brackets. ‘>>’ should be written as ‘> >’ as shown in the example below. #include   typedef std::vector vec2;  // OK   int main() { } Or you should change your C++ compiler so that it supports C++11 or above. C++17 is recommended. Note that the latest RAD Studio, C++ Builder standard and CLANG compilers supports C++17 features. What is the right-angle bracket support in C++ 11? In the Clang-enhanced C++ compilers, two consecutive right-angle brackets no longer generate an error, and these constructions are treated according to the C++11 standard.This example below with ‘>>’ right angle brackets can be successfully compiled with any compiler that supports C++11 and above. #include   typedef std::vector vec1;  // OK C++11 and above   int main() { } For more information, see the C++11 proposal document at Right Angle Brackets Proposal document

Read More