top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

What is "Auto Storage Class Variables" and how to define it using C++?

0 votes
53 views
What is "Auto Storage Class Variables" and how to define it using C++?
posted Jul 5, 2017 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Auto Storage class variables are created each time a function executes and disappear when the function terminates. In other words, the duration of an automatic variable is the duration of the function in which it is declared ad the scope is the function's code. It can be accessed only in that function. Local variables are by default classified as auto variables, because they are allocated automatically when a function is executed and deallocated automatically when the function terminates. Hence, automatic variables cannot retain their values over a number of function calls to that function.
To declare a local variable as automatic, the keyword auto is placed at the head of the declaration:-

auto int i_value;

Since auto is the default storage class for local variables, this keyword is usually omitted. It should also be noted that global variables cannot be declared as auto.

answer Jul 5, 2017 by Kumar Neeraj
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...