What does the 'm' mean?

This is a discussion on What does the 'm' mean? within the C++ Programming forums, part of the General Programming Boards category; Hello, I didn't see any kind of beginners board so I hope you guys don't mind me asking this silly ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    2

    What does the 'm' mean?

    Hello,

    I didn't see any kind of beginners board so I hope you guys don't mind me asking this silly question here...

    Ok, I see this all the time but I've never known what the heck it is; looking at this little snippet:
    Code:
    class Polygon
    {
    	vector<vec3f>	m_vertex;
    	list<m_vertex>	m_points;
     	list<m_points>	m_ploygon;
    };
    What does the 'm' in the variable’s name mean?

    Thanks,

    -=GB=-

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >What does the 'm' in the variable’s name mean?
    Member.
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    it's probably a memory device, sort of like hungarian notation where the first several letters of a variables name signify it's type. The m is meaningless. It could just as easily have been j_points, pretty_points, toomany_points, or some other equally inoffensive, or offensive if you wish, name. m may have stood for map or some other word starting with m. doesn't really matter.

  4. #4
    Registered User manofsteel972's Avatar
    Join Date
    Mar 2004
    Posts
    317

    It is a Microsoft version of Hungarian Notation

    Object member variable.
    "Knowledge is proud that she knows so much; Wisdom is humble that she knows no more."
    -- Cowper

    Operating Systems=Slackware Linux 9.1,Windows 98/Xp
    Compilers=gcc 3.2.3, Visual C++ 6.0, DevC++(Mingw)

    You may teach a person from now until doom's day, but that person will only know what he learns himself.

    Now I know what doesn't work.

    A problem is understood by solving it, not by pondering it.

    For a bit of humor check out xkcd web comic http://xkcd.com/235/

  5. #5
    Registered User
    Join Date
    Mar 2004
    Posts
    2
    Member! That's it!

    elad, that might have been it but I forgot to mention that I've seen this all over the place. It's quite common.

    Thanks guys! Mystery solved.

    Still, it's kind of odd. Why use this notation? You already know it's a member by the simple fact that you have to go through it's object just to access it.

    ply.m_point[currentPoint] = next;

    how could m_point not be a member?


    Thanks!

    -=GB=-
    Last edited by galenb; 03-03-2004 at 09:20 PM.

  6. #6
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    It's not always so easy to remember the type of a variable, just by looking at the name. Thus the use of hungarian notation to help you out. If might be helpful if your program has 300 variables in it, say as in code for an OS, etc.

    If your company has a policy that all variables need to have hungarian notation, then using m_ preceding the name of a member variable is as good as anything.


    Or maybe its mean to remind the user that you are dealing with a variable and not a function. If there's hungarian notation in front of the identifier, it's a variable. If there's a () after the identifier, it's a function.

    Again, it's just an aid to the memory of the people who are writing the code. Might not make sense to us, but it does/did to them.

  7. #7
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003
    Posts
    314
    Originally posted by galenb
    how could m_point not be a member?
    When used from inside the class it could either be a global variable, a parameter variable or a member variable.

    I don't use any prefix for members, but I can understand that it makes sense in larger projects. I'm just prefixing the variable type or base type if it is a type iCount, CMyClass, EMyException etc...
    [code]

    your code here....

    [/code]

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21