Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the m in mVariableName mean? [duplicate]

Tags:

c++

naming

I've seen several occurrences in tutorials where i variables with an "m" in front of the actual name. At first I thought it meant "my" but after really keeping a lookout for these "m"'s I'm no longer sure what it means. Does anyone know where this convention comes from?

like image 874
Daniel Figueroa Avatar asked Sep 10 '11 09:09

Daniel Figueroa


People also ask

What does the M variable mean?

As stated in the other answers, m_ prefix is used to indicate that a variable is a class member. This is different from Hungarian notation because it doesn't indicate the type of the variable but its context.

Why do variable names start with M?

The use of the "m" prefix is more specific that simply denoting a "member" variable: It's for "non-public, non-static field names." Great link, not just for prefixes.

What does M mean in coding?

M-code (for “miscellaneous function”) is an auxiliary command; descriptions vary. Many M-codes call for machine functions like “open workstation door,” which is why some say “M” stands for “machine”, though it was not intended to.

What does M mean in Java?

Letter m as prefix means that it is member of class. Letters lv means that it is local variable. Letters pm means that it is parameter. example: class Example { Integer mMemberOfClass; public void someMethod(Object pmSomeParameter) { Integer lvSomeLocalVariable; } }


2 Answers

m is to indicate that it is a member variable, it is common variant on Hungarian Notation. Other common prefixes to look out for are I for interface and C for class.

Depending on the language, it is also common to prefix s for string and b to indicate a boolean.

like image 111
Dennis Avatar answered Sep 19 '22 00:09

Dennis


It's commonly used to mean that variable is a member of class. For example it's useful in situations like this:

someclass::somefunc()
{
...
.
.
  m_myvar = 1;
  lvar = 2;
.
.
.
}

You can tell at a glance that m_myvar is a member of someclass but lvar is not.

like image 28
sashang Avatar answered Sep 22 '22 00:09

sashang