daily pastebin goal
56%
SHARE
TWEET

Untitled

a guest Dec 12th, 2018 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. int main() {
  4.  
  5.     int x = 10;
  6.     int y = 22;
  7.     int *ptr = &x;  // ptr'ye x'in adresi ile ilk deger verdik
  8.  
  9.     *ptr = 20;  // x = 20
  10.     int *&r = ptr;  // r p ptr'nin yerine gecen bir isim, ptr'ye bir referans al
  11.     r = &y;  // ptr'ye y'nin adresini atamak demek    *r artik y
  12.     ++r;
  13.  
  14.     std::cout << "x -> " << x << std::endl;  // x -> 20
  15.     std::cout << "y -> " << y << std::endl;  // x -> 22
  16.  
  17.     return 0;
  18. }
  19. #include <iostream>
  20.  
  21. int main() {
  22.  
  23.     int x = 10;
  24.     int *ptr = &x;  // ptr x'i gosteriyor
  25.     int **p = &ptr;  // p ise ptr'yi gosteriyor
  26.  
  27.     int **&r = p;  // r demek = p demek
  28.     ++**r;  // r'nin yerine gecen x'i arttir
  29.  
  30.     std::cout << "x -> " << x << std::endl;  // x -> 11
  31.  
  32.     return 0;
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top