What's the use of auto in C++?
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