Guest User

Untitled

a guest
Dec 12th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <iostream>
  2. int main() {
  3.  
  4. const int x = 10; // const semantigi
  5.  
  6. int *ptr = &x;
  7. // Cannot initialize a variable of type 'int *'
  8. // with an rvalue of type 'const int *'
  9.  
  10. return 0;
  11. }
  12. #include <iostream>
  13. int main() {
  14.  
  15. const int x = 10; // const semantigi
  16.  
  17. int &r = x; // Binding value of type 'const int' to reference to type
  18. // 'int' drops 'const' qualifier
  19. // const T x turunden T x turune donusum YOK
  20.  
  21. const int &r = x; // GECERLI
  22.  
  23. return 0;
  24. }
  25. #include <iostream>
  26.  
  27. void func(int &r); // sabit gonderemeyiz
  28. void foo(const int &r); // okuma yapacagimizi belirttik - const
  29.  
  30. int main() {
  31.  
  32. func(10); // GECERSIZ
  33.  
  34. foo(10); // GECERLI
  35.  
  36. return 0;
  37. }
Add Comment
Please, Sign In to add comment