Get the App
SLTechnology News&Howtos  ›  Development  › 

What's the use of auto in C++?

Shulou Source: shulou.com Published: 2022-06-02 00:38:56 09月30日 Update

This article mainly shows you what the use of auto in C++ is, the content is simple and clear, and I hope it can help you solve your doubts. Let the editor take you to study and learn this article "what is the use of auto in C++?"

1.auto introduction

In the early days, the meaning of auto in Cauto + was to use a variable modified by auto, and auto was a local variable with automatic memory.

The standards committee of auto 11 gives a new meaning to auto: auto is no longer a storage type indicator, but as a new type indicator to instruct the compiler, the variables declared by auto must be derived by the compiler at compile time.

You can use typeid (). Name to print the type of object.

Case study:

Int TestAuto () {return 2;} int main () {int a = 10; auto b = a; auto c = 'a'; auto d = TestAuto (); cout

Tags: Types compilers variables compilers actual instructions centering content one line meaning multiple that is pointers cases case studies articles results expressions analysis storage Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Huawei OPPO Reno Apple macOS