Naming Variables in C++

Rackham

Baseband Member
Messages
21
Im just beginning to learn C++ and I am having trouble understanding why the variables in many sample source codes begin with a letter such as n or d.

Such as
int nVariable

Any help would be appreciated
thanks
 
because the programmers chose to name them that way. When naming a variable its important to choose a name following to rules:

1) when you see the name, you know instantly what the variable is for.

2) names should not conflict (e.g. int hey; char hey;) namespace solves this problem.

so i suppose that the name nVariable should remind the coder that nVariable is an integer that will be used for whatever purpose.

Sometimes there are guidelines set up on choosing names. See whomever is responsible for the source and ask what these guidelines are, if they exist.
 
Back
Top Bottom