Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

m_ 2

Status
Not open for further replies.

bubak

Programmer
Jun 25, 2001
208
SK
Maybe a stupid/simply question, but...
what do "m_" in variable name mean? When do I use it?
thx
bubak
 
It just means that it's a member varible...you don't have to use it if you don't want to. It's just there for readablility. At least, this is what I believe it means...someone correct me if I'm wrong.

Niky Williams
NTS Marketing, Inc
 
Yes, I know, that it needn't to be used, I just wanted to know, what it means, if it's sth from hungarian notation or so,....
 
Valius is correct. It is a member variable (meaning a variable within a class) A simple example of its use would be on a dialog based app. Through the use of the class wizard you can assign a member variable to a control on the dialog.

1. Create a new project
2. Make it a dialog based app
3. put an edit box on the dialog
4. right click the dialog and go to class wizard (i have noticed that you may need to build the project at least once before you see all the controls in the class wizard)
5. Select your control
6. Add a member variable of type cstring
7. Add a button and use the class wizard for on click
8. Edit the code to pop up a message box to display what is currently in the edit box

Through the use of UpdateData(TRUE/FALSE) you can fill the edit box with what is in the memeber variable or vice versa.

This is a broad explanation but I hope it helps.

Matt
 
Yes, I've noticed "m_"s in variables for MFC classes, created with MFC class wizard, now, I'm working on a few non mfc classes, so I cannot use Class Wizard and I'm asking, coz I want to now, If I use m_ prefix correctly.
 
I really don't ever use the "m_" naming scheme...I used to when I used MFC...but I've gotten into the Win32 aspect of it and haven't used it. I've kinda come up with my own naming scheme but still using some of the conventional namings. Do what is most comfortable for you.

NWW
 
m_ represent that it is the member variable of that class
is
m_ == member variable
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top