Reading assignment - auto variables


#21
  • What is an auto variable?
    An auto variable it’s a variable whose type will be automatically deduced from its initializer.
  • Why is it convenient to use?
    It makes the code easy to write and comprehend. But we should avoid abuse.
  • When should you use it?
    When we need to cut down unnecessary typing of complex data types on the left hand.
  • When will the type of an auto variable be determined (compile-time or run-time?).
    It will be determined at compile time. Also the auto keyword forces the initialization of variables.

#22
  1. What is an auto variable?
  • No need to declare the type of variable beforehand, it will auto-detected the type.
  1. Why is it convenient to use?
  • no need to specific the variable type
  1. When should you use it?
    when we want to declare the type of variable after the initializer type is declared.
  2. When will the type of an auto variable be determined (compile-time or run-time?)
    compile time

#23
  1. What is an auto variable?
    Auto variable is a variable-type specifier that is not explicitely declared and it is dynamically assigned a data type (float, int, etc.).

  2. Why is it convenient to use?
    Makes working with C++ variables easier because you do not have to strictly say what type of variable you are working with. Once the type of the initializer has been determined, the compiler determines the type that will replace the keyword auto.

  3. When should you use it?
    Most useful when you are writing robust code that can handle different types of inputs. More specifically when working in a block scope or namespace scope.

  4. When will the type of an auto variable be determined (compile-time or run-time?)
    Compile time. Once the type of the initializer has been determined, the compiler determines the type that will replace the auto variable.


#24
  1. Auto Variables in C++ are used to automatically assign a type to the following variable name.
  2. It is convenient because it helps simplify the code by letting C++ compiler figure out the type of the variables.
  3. It may be used everywhere C++ compiler can clearly deduct the intended type and avoided when there might be ambiguity nor misunderstanding.
  4. Of course the compiler will check and find the appropriate type of the variable.

#25
  1. What is an auto variable?
    An auto variable is a variable that lets C++ decide what a datatype following the initialization. C++ will automatically decide if the variable is a string, int, or double etc based on what is initialized.

2.Why is it convenient to use?
Using the ‘auto’ specifier is convenient because it lets C++ do the deciding. Say we use auto for our variables and functions. If we were to change the data type of elements within the function, ‘auto’ would change the data type for us. This could be useful for things like changing a piece of the API, and if the client side code was using auto, they would not even notice the difference.

  1. When should you use it?
    We should use auto specifiers when we are sure that our code will not crash should there be a change in data type. Auto is convenient, but it could lead to some problems down the road if not used carefully.

  2. When will the type of an auto variable be determined (compile-time or run-time)?
    The type is determined during compile time, where the compiler will determine the type and replace it with the auto keyword.


#26

1.It is a variable whose type will be automatically deduced at compile time
2.Allows more flexibility to code
3.When you are unsure of the type of the variable that will be used.
4. The type of the auto variable will be determined at compile-time


#27
  1. An auto variable is one that will be automatically deduced from its initializer.

  2. It can be used when the value is not known beforehand. The compiler will automatically fill the missing gaps at once across multiple functions as needed.

  3. It gives flexibility with data that is entered and can later be changed.

  4. Compile-time.


#28
  1. What is an auto variable? auto variables specifies that the type of variable that is being declared, will be automatically deduced from its initializer.

  2. Why is it convenient to use? it saves the programmer time with type specification.

  3. When should you use it? When declaring variables, in block scope, in namespace scope, in initialization statements of for loops. etc.,

  4. When will the type of an auto variable be determined (compile-time or run-time?) The compiler determines the type.


#29
  1. A data type specifier that attempts to discern the necessary data type automatically
  2. Sometimes the data type of a return is uncertain, or perhaps a variable may need an int or string depending on a situation, etc.
  3. It should only be used when data type discernment is needed during compile time and the scenario calls for flexibility
  4. " Once the type of the initializer has been determined, the compiler determines the type that will replace the keyword auto" - so compile time.