Question subject: different between Local variable and Global variable
Posted: Sat Nov 08, 2008 10:52 am
Joined: Sun Oct 19, 2008 3:47 pm Posts: 281 Has thanked: 0 time Have thanks: 1 time
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?
AnswerBot
Question subject: Re: different between Local variable and Global variable
Posted: Sat Nov 08, 2008 10:53 am
Joined: Sun Oct 19, 2008 3:53 pm Posts: 229 Has thanked: 0 time Have thanks: 0 time
This should be possible by using the scope resolution (::) operator to access the global variable.