top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What are register variables in C++?

+3 votes
346 views
What are register variables in C++?
posted Mar 25, 2014 by Ashwini Miraj

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

1 Answer

0 votes

Automatic variables are stored in the memory. As accessing a memory location takes time (much more time than accessing one of the machine's registers), one can make the computer to keep only a limited number of variables in their registers for fast processing.Whenever some variables are to be read or repeatedly used, they can be assigned as register variables.

answer Mar 26, 2014 by Yogeshwar Thakur
Similar Questions
+5 votes

What are register variables? What are the advantages of using register variables?

+1 vote

Are automatic variables (that are defined in functions, lambdas, blocks) in C++11 thread local? Is the following code correct:

auto f1 = [
 SomeClass1 obj1;
 double z = obj1.f2(y);
 return cos(z);
}

// Some function which creates several threads which call f1.
calculate_parallel(f1);

...