C:Pointeurs et valeurs
De WIKI.minetti.org
Déclarations et obtention des pointeurs et valeurs
Déclaration | Pour obtenir | Suppression | |
---|---|---|---|
la valeur | le pointeur | ||
int val; | val | &val | automatique |
int *pt; | *pt | pt | à désalouer si allocation dynamique |
Object obj; | obj | &obj | automatique |
Object obj(param1, param2); | obj | &obj | automatique |
Object *obj = new Object; | Delete obj; |
Passage de paramètres
Type | Déclaration paramètre | Notation variable suivant sa déclaration | |
---|---|---|---|
int val | int *pt | ||
Par valeur | int val | val | *pt |
Par pointeur | int *pt | &val | pt |
Par référence | int &val | val | *pt |
Compatibilité des déclarations
- int tab[100] <=> int *tab
- int tab[] <=> int *tab