Pages: [1]   Go Down
Author Topic: _ or __ in front of variables  (Read 706 times)
0 Members and 1 Guest are viewing this topic.
NZ
Offline Offline
Sr. Member
****
Karma: 0
Posts: 390
Turtle in a hard shell
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello

Newbie question here - but I have noticed on a few peoples example programs, the use of _ or __ in front of some variables. I was just wondering what the purpose of these underscores is?

Do they serve a purpose, or are they just so the variables stand out or something?

Thanks
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 46029
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Typically, the underscore is used in front of member variables in a class, to distinguish them (for the reader) from local variables. The presence or absence of the _ (or __) makes no difference to the compiler.
Logged

NZ
Offline Offline
Sr. Member
****
Karma: 0
Posts: 390
Turtle in a hard shell
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks
So by 'member variables' you mean what I would call 'Global Variables' ?

As in variables that can be used throughout the sketch rather than local ones to a function.

Sorry coming from IEC PLC programming to this and still learning.

Since they have no effect to the compiler, that is good to know.

Thanks
Logged

Nowhere
Offline Offline
God Member
*****
Karma: 3
Posts: 852
|-\ |\|\
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
So by 'member variables' you mean what I would call 'Global Variables' ?

No, not at all, sorry.

What he means is variables that are part of a class.  
Not global, not local in a function, but in a separate class.
Logged

Soundcloud page: http://soundcloud.com/beefinator-2
Youtube channel: http://www.youtube.com/user/beefinator14
Old soundcloud page (ran out o

Pages: [1]   Go Up
Jump to: