The Saint
April 19th, 2005, 03:15 AM
Hi all,
The other day I had a dicussion with my friend on why we use such notations as m_, l_, g_ and how can the user know whether the particular variable is public/protected/private.
I thought that I can share this with you all and also know the other views or reasons. So here it goes.
The variables are prefixed by the following;
m_ for member variables
l_ for local variables
g_ for global variables
x_s for static variables and so on.
This was quite straight forward. The other issue was how would the user (programmer) know about the access of a variable.
Well, one thing is that almost all IDE's follow UML notations. So they use the UML notations for public/protected/private to denote the access. Moreover there are numerous plugins similar to the Intellisense of Visual Studio which display these notations thus making it possible for a programmer to know the access. Moreover the normal suggestion is to always declare public, protected and private in that order so that the user will be able to locate the variable/methods in that order.
In most cases, the header file is always released to the user and this order would help the user know the access.
Please pool in with your valuble thoughts.
The other day I had a dicussion with my friend on why we use such notations as m_, l_, g_ and how can the user know whether the particular variable is public/protected/private.
I thought that I can share this with you all and also know the other views or reasons. So here it goes.
The variables are prefixed by the following;
m_ for member variables
l_ for local variables
g_ for global variables
x_s for static variables and so on.
This was quite straight forward. The other issue was how would the user (programmer) know about the access of a variable.
Well, one thing is that almost all IDE's follow UML notations. So they use the UML notations for public/protected/private to denote the access. Moreover there are numerous plugins similar to the Intellisense of Visual Studio which display these notations thus making it possible for a programmer to know the access. Moreover the normal suggestion is to always declare public, protected and private in that order so that the user will be able to locate the variable/methods in that order.
In most cases, the header file is always released to the user and this order would help the user know the access.
Please pool in with your valuble thoughts.