Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

How does C++ determine variable location on the stack?

$
0
0
Correct me if I am wrong, but in the function "doub", a new variable scope is entered, correct? I am interested in knowing how C++ determines the stack location of "x". When it swaps to the new variable scope, does it take note its "distance" from the other variable scopes in case it has to call a local variable from a different scope or what?

int main()
{
	int x;
	int doub()
	{
		return 2*x;
	}
	return 0;
}


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>