Switch to full style
For C/C++ coders discussions and solutions
Post a reply

different between Local variable and Global variable

Sat Nov 08, 2008 10:52 am

I'm having a class with lots of variables, and each one has a set get method.
Its actually not very important but I hate having too much names in a class.

For example i have a method that require a parameter var1, and the name var1
already used by the global variable. In java we can access both by using
this.var1 for global variable and var1 for local variable.

Is it possible to do the same in C++? How can I do it?



Re: different between Local variable and Global variable

Sat Nov 08, 2008 10:53 am

This should be possible by using the scope resolution (::) operator to
access the global variable.

Post a reply
  Related Posts  to : different between Local variable and Global variable
 how to call a global variable?     -  
 Calling a local variable from a static function     -  
 transient variable     -  
 PHP variable in javascript     -  
 Unset variable     -  
 Variable interpolation     -  
 Passing a Reference Variable     -  
 Variable Size Arrays     -  
 Testing the Type of a Variable     -  
 Delete session variable     -