Hi,
First, a golden rule for programming:
Always initialise your variables
I like to do this as part of the declaration.
What is the value of nAge on line 14? I am picking quite a large number, maybe even negative. Should line 14 be moved to elsewhere in your program?
Think about the types of your variables - is
int
a good type for someone's name? For the others consider making them
unsigned
.
With your variable names:
Does the
n
in front of the variable name mean number? If so, don't bother with that. It is a form of Hungarian Notation which is generally bad because it can be overdone and confusing, unless used for it's original purpose (which is rather different form the way it was abused by Microsoft, and different to what a lot folks think it is). See the article below.
Having said that I put prefixes on several things (and limit it to that):
C
for class ;
p
for pointer ; and
m_
for class member variables.
Don't be afraid to make the variable name a bit longer if it improves it's meaning. For example
BirthDate
is better than
Date
IMO.
Good variable names help self document code, and comments are good for describing what functions do, expected ranges of values, expected output values etc.
Don't
#include
header files you don't need.
Finally don't have line 7, put
std::
before each
std
thing - Google to see why that is so. I wish Bjarne Stroustrup and other authors and lecturers would quit doing it.
With this article:
http://www.joelonsoftware.com/articles/Wrong.html
which describes the original intention of HN, the second part entitled "I’m Hungary", describes how it all went wrong.
I still have a problem with the use of
us
as a prefix. To me that immediately conjures
unsigned
to others it might mean "United States". IMO it would be ok if it were the prefix
Unsafe
. Another is
sz
, to me this is an obvious acronym for "size", not "zero terminated string".
I do think the concept of Safe and UnSafe strings is a good one though.
The
stdint.h
has types in it that refer to specific widths in bits and sign:
int8_t
int16_t
int32_t
uint8_t
uint16_t
uint32_t
http://en.wikipedia.org/wiki/Hungarian_notation