Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
C++CodeIDERAD Studio

Learn How To Use Auto-Typed Variables In C++ For Windows Development

Auto-typed variables is a C++11 feature that allows the programmer to declare a variable of type auto, the type itself being deduced from the variable’s initializer expression. The auto keyword is treated as a simple type specifier (that can be used with * and &), and its semantics are deduced from the initializer expression.

auto-typed Variables Examples

Multi-declarator auto

The C++11 standard includes the multi-variable form of auto declarations, such as:

The restriction with multi-declarator auto expressions is that the variables must have the same base type. For example, the following line of code is well-formed:

because x and y have the same base type : int, while the following code:

will generate the error: [bcc64 Error] File1.cpp(11): 'auto' deduced as 'int' in declaration of 'x' and deduced as 'double' in declaration of 'y'. This feature is supported by the Clang-enhanced C++ compilers.

Check out all of the modern C++ language features supported in the latest C++Builder for Windows development.


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

Related posts
DelphiShowcase

Impressive Logistics Provider ERP And Operations Solution Is Created With Delphi

DelphiShowcase

Astonishing 3D Train Simulation Software Displays Delphi Flexibility

DelphiShowcase

A Brilliant Cloud-Based System For Circuit Boards Is Powered By Delphi

DelphiShowcase

MFL Is A Fun Programming Language That Is Delphi Powered

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES