It's taken from the C++ primer book however the explanation is so exact that even after reading, it is a pleasure to revise the knowledge from your content. Thanks keep going!!!
Hello Sir, i have a doubt if we write const int i = 100; const int &ptr = i; // ptr is refrence to const so we can not change the value of i using ptr that's fine i,e ptr = 11; is illegal but when we write int j = 19; const int & ptr1 = j; // here ptr1 is not "reference to const" rather it's reference to a non const so, writing ptr1 = 1222; should be legal but it's not y?
// take an example below int i = 50; // when a pointer is declared like this (1 consts) const int* p = &i; // The "const" does not mean a pointer is a constant, it's for the bounded object "i". it simply adds a restriction to the pointer as below. // WHICH MEANS // YOU CAN'T CHANGE VALUE OF POINTED TO OBJECT USING THIS POINTER. -----------------------------------PHASE 2------------------------------------------- // if you want a constant pointer, then do this (2 consts) const int *const p1 = &i; // the 1st "const" means, you can not change the value of the bounded object "i" using the pointer // the 2nd "const" means the pointer is a constant, meaning you can't reassign it or change the address it points to
So const int &r1 can be read as "r1 is a reference to an int const". Basically, r1 refers to an int which cannot be modified. This means that the referred-to int is either a const int, or it's a simple int.
It's taken from the C++ primer book however the explanation is so exact that even after reading, it is a pleasure to revise the knowledge from your content. Thanks keep going!!!
So glad that I found this channel.. You explain really well..
Please do all c++ from basic to advanced.
thank you doctore
you dont know how much you are great
yiur amazing in explaining
keep goint
Excelente explicación. Gracias!!!
I love Neso Academy. ❤️
This is probably the most confusing topic in whole C++
Please upload video that will talk about how to code faster in vscode
yesterday didn't upload any video 😕 😢 😪 😔. why?sir!!!!!!!
Sir help me for clarifying this c++
Thanks sir plz upload daily
looking forward for the oop topic
❤️❤️❤️
Hello Sir, i have a doubt
if we write
const int i = 100;
const int &ptr = i; // ptr is refrence to const so we can not change the value of i using ptr that's fine i,e ptr = 11; is illegal
but when we write
int j = 19;
const int & ptr1 = j; // here ptr1 is not "reference to const" rather it's reference to a non const so, writing ptr1 = 1222; should be legal
but it's not y?
// take an example below
int i = 50;
// when a pointer is declared like this (1 consts)
const int* p = &i;
// The "const" does not mean a pointer is a constant, it's for the bounded object "i". it simply adds a restriction to the pointer as below.
// WHICH MEANS
// YOU CAN'T CHANGE VALUE OF POINTED TO OBJECT USING THIS POINTER.
-----------------------------------PHASE 2-------------------------------------------
// if you want a constant pointer, then do this (2 consts)
const int *const p1 = &i;
// the 1st "const" means, you can not change the value of the bounded object "i" using the pointer
// the 2nd "const" means the pointer is a constant, meaning you can't reassign it or change the address it points to
@@mayobyohassan500 jhakkas explanation boss 🤙
So const int &r1 can be read as "r1 is a reference to an int const". Basically, r1 refers to an int which cannot be modified. This means that the referred-to int is either a const int, or it's a simple int.
😮