0

Click Here

I thought after the function call of gen_aux before the loop, the static call on the type for r should have make it declared. but why not?

how static really works? this is what it's explained in the books:-

static type variable;

For local declarations, declares variable with static storage class. The value of variable persists across executions of this scope and is guaranteed to be initialized before the variable is used for the first time. When the program exits from the scope, the variable keeps its value until the next time the program enters that scope. We'll see in ยง13.4/244 that the meaning of static varies with context. 
3
Contributors
2
Replies
20
Views
4 Years
Discussion Span
Last Post by sepp2k
0
    static methods can not access non-static class members because the static method has no idea what instance of the class the variable r belongs to.  
0

Making a local variable static means that it will remember its value between multiple calls of the same function. It does not mean that other function can access that function. A variable that is defined within one function can't be accessed from other functions (at least not directly - it's possible through pointers or references of course). Making the variable static doesn't change that.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.