C++ da &
int rats=101;
int & rodents=rats;
cout << "rats = " << rats;
cout <<", rodents = " <<"\n";
rodents++;
cout << "rats = " << rats;
cout <<", rodents = " <<"\n";
cout<< "rats address = "<<&rats;
cout<<", rodents address = "<<&rodents<<"\n";
Yukaridaki program su sekilde sonuc uretir:
rats =101, rodents = 101
rats =102, rodents = 102
rats address = 0068fdff4, rodents address = 0068fdff4
Yani & bir adres alma islemi degil, sadece bir takma ad tanimliyor. Degerini tanimlarken ataman gerekli ve degistiremiyorsun.
int & rodents = rats bir anlamda
int * const pr = &rats ve *pr=rodents
int & rodents=rats;
cout << "rats = " << rats;
cout <<", rodents = " <<"\n";
rodents++;
cout << "rats = " << rats;
cout <<", rodents = " <<"\n";
cout<< "rats address = "<<&rats;
cout<<", rodents address = "<<&rodents<<"\n";
Yukaridaki program su sekilde sonuc uretir:
rats =101, rodents = 101
rats =102, rodents = 102
rats address = 0068fdff4, rodents address = 0068fdff4
Yani & bir adres alma islemi degil, sadece bir takma ad tanimliyor. Degerini tanimlarken ataman gerekli ve degistiremiyorsun.
int & rodents = rats bir anlamda
int * const pr = &rats ve *pr=rodents
Etiketler: CPP
Toplam 0 Yorum:
Yorum Gönder
<< Ana Sayfa