I wish this help you You've got it right although there are some wrinkles. Class variables (@@foo) can be accessed both from the class methods and the instance methods of a class. They behave somewhat unintuitively with respect to inheritance: if you set such a variable in a base class and set it again in the subclass then you will change the value for all classes in the hierarchy. If you're using class variables to store settings this is often not what you want - you want subclasses to be able to "override" values from the base class without actually changing them for the base class. Rails provides class_attribute for this: it creates accessor methods which have that behaviour.
Is it dangerous to have local variables refer to other local variables?
seems to work fine Using local variables, each time a thread calls your method creates a new instance of these variables, that are not available to any other thread (unless you specifically allow for passing the references). So, no other thread can modify your objects. Using global (I think you mean instance variables, attributes), all of the threads that have access to your object has access to those attributes of the object (let it be directly, let it be by running your object methods) and can modify them while your other thread is running the iteration. Since the iterator can detect when the Collection that is being iterated has been modified, when this happens it throws the exception (which means nothing else that "I was iterating all of the objects of the collection but these objects are no longer the same so this is too confusing and I fail".
Are variables for pass by value variables and local variables in a function not allocated continuously?
This might help you In C (not sure about C++ but I suspect it's similar), there is no relationship between addresses of separate objects. The language does not even define an order relation on them; the >, <, <=, and >= operators have undefined behavior when used on pointers that do not point into the same array. As for why objects end up with particular relationships between the numeric addresses of pointers to them, that's purely a consequence of implementation details of the compiler and it depends on the specific compiler, compiler version, and options used.
How to access the ICElements of local variables(variables inside function) and variables in header file?
I wish did fix the issue. Local variables ICElement is mostly used for representing code elements in CDT's various views, such as the Outline View or Type Hierarchy. As such, local variables (which do not appear in these views) do not have an ICElement representation.