mardi 6 août 2013

Learning C++ Step by Step : Naming your variables

This is the second tutorial ( Naming your variables ) this is only a simple explaining on how to name your variables it will not include YouTube video, In the last Tutorial ( Hello world ) I explain how to create a " hello world " program, I try to include all problems you may face while coding your first program ( Hello world ).



 In This tutorial I will talk a little bit about variables and how to name them, well in fact I won't talk about variable definition, just going to explain few things before starting our third tutorials ( Variables)

 What names Can I use ? 
You can use those examples :
- B6
- X_ray
- Deadrou
- Tab
- Counterrr
- Door12
- Table_Integer

C++ is as all other programming language ( Pascal, python , c etc..) it's better if you name your variable a closer name to the role of the variable for example :

You are going to use a variable that contain a name than name it " nam , name , prenom ect.. " 
You are going to use a variable that contain an address than name it " adr , _adress etc.. "

What names I can't use ?
Those are some examples of names you can't use while naming a variable in c++ and for each example I include the reason why it can't be used ?

- 4bro : Because it start with number 
- my.name : Because it used the symbol ( . ) instead it can be used if we change (.) with ( _ ) 
- Sami++ : Because it used the symbol ( + ) 
- Camus# : Because it used   the symbol ( # )
- Me_乙 : Because it use a chinos word (乙)

Note : ! The only keyboard symbol that can be used while naming your variable is ( _ ) 

 Almost forget something really important, c++ language have something to distinct it from other languages witch is the difference between " A " or " a " as an example, In other languages it really doesn't matter if you type " Amin " or " amin " but in C++ it do matter so...

Also you can not name a variable the same name as a function name 
Example : You cannot name a variable " Void " , " int " or " default " because those are Reserved words for c++ language.


C++ language have only 56 reserved word ( function ) not like other language and this is why I am teaching it to you guys because if you become a c++ programmer, well welcome to money world even it's not popular and wanted as java do.


I guess it's all explained now, The next tutorial will be about numbers, variables and more. 

 

1 commentaire:

  1. Have you been searching for ways to get popularity quickly? You merely will need to Buy Facebook Followers to become renowned online. buy real followers for facebook

    RépondreSupprimer