Variable prefixes in (Microsoft) Visual C++

Posted on 2003-03-06
Medium Priority
Last Modified: 2013-12-14
I have recently had to undertake a project using Visual C++, a language and programming paradigm that I'm not yet familliar with.  My question should be fairly basic for anyone involved in Visual C++ programming or possibly programming in general.

I have seen many prefixes on variables such as:


... and many (all?) of these variables have been declared using some of:


So my question is this:  Is there a good reference on what the individual prefixes and macros for declaration mean?

Question by:Sparky961
  • 3

Expert Comment

ID: 8081299
Try MSDN(Microsoft Developer Network)


Author Comment

ID: 8081776
I have already been wandering through the endless maze of MSDN quite a bit.  I was hoping for a summary from someone that already knows this information instead of the lengthy process of piecing together this information.

LVL 12

Accepted Solution

Salte earned 200 total points
ID: 8082071
This is the so-called hungarian notation.

Note that microsoft has departed from that notation in .NET. It is a thing of the past and personally I think it is good. The names tended to be very 'artificial' and if you write small functions or with declarations close to where they are used there should be no need to indicate by the name what type the variable is. If you put the declaration far away from where it is used, perhaps you should rather move the declaration.

From this you might think that global variables should still have the prefix but I would say no.

Global variables should in general be very few and only rarely of simple types. Most global variables should be classes which are specific anyway and it isn't really much information to use a prefix to say that 'this variable is a class'. What is interesting to know then is WHAT class. However, even for global variables, if they are reasonably named then you can usually guess the type.

a name like 'distance' is some form of scalar type and measure the distance in some form related to the program. There's no need to say that it is integer or double, that kind of info is just disturbing so 'iDistance' or 'dblDistance' wouldn't make much sense.

Anyway, Microsoft has full documentation about each prefix and what they mean. Please note though that that info isn't absolute, I have seen code from microsoft which didn't always follow all those recommendations completely.

Anyway, I will strongly urge you to NOT use hungarian notation in your own code. It might be useful to know when you read MS code though but don't use it yourself.

Once again a MS feature which is largely useless :-)


Author Comment

ID: 8082177
If someone can point me directly to a list, they can have the points...


Author Comment

ID: 8082209
Unfortunately, the project that I'm working on started it's life as a template and I don't think it would be wise to change variable names at this stage. ;)

I thank you for the explanation, and I have FINALLY found a reference for all of these prefixes.


Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

593 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question