11.07.2015 Views

tYSR20

tYSR20

tYSR20

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 2: Declaring Variables Constantly37Naming conventionsYou may have noticed that the name of eachvariable begins with a special character thatseems to have nothing to do with the name.These special characters are shown in the foldVariableas a variable of type double bylowing table. You can immediately recognizeusing this convention.CharacternlfdcszTypeintlongfloatdoublecharacterstringThese leading characters help the programmerkeep track of the variable type. Thus, you canimmediately identify the following as a mixedmodeassignment of a long variable to an intvariable:nVariable = lVariable;These leading characters have no significanceto C++. You don’t need to adopt any namingscheme at all if you don’t want to. Here’s whatyou get:double myVariable;int someIntValue;double nThisDoesntEvenMatch;I used this first-letter-naming convention in thischapter to simplify the discussion; many programmersuse this naming scheme all the time.Mixed-mode expressions are not a good idea. Avoid forcing C++ to do yourconversions for you.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!