Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main() {
- const int x = 10; // const semantigi
- int *ptr = &x;
- // Cannot initialize a variable of type 'int *'
- // with an rvalue of type 'const int *'
- return 0;
- }
- #include <iostream>
- int main() {
- const int x = 10; // const semantigi
- int &r = x; // Binding value of type 'const int' to reference to type
- // 'int' drops 'const' qualifier
- // const T x turunden T x turune donusum YOK
- const int &r = x; // GECERLI
- return 0;
- }
- #include <iostream>
- void func(int &r); // sabit gonderemeyiz
- void foo(const int &r); // okuma yapacagimizi belirttik - const
- int main() {
- func(10); // GECERSIZ
- foo(10); // GECERLI
- return 0;
- }
Add Comment
Please, Sign In to add comment