Can you please elaborate on the explicit typecasting method taught in the video using which & operator can be used with character variables…
Problem in understanding a concept taught in this video
Hi Ayush, see the & operator provides address of a variable, but while outputting it for char variable(cout<<&a where ‘a’ is char type) it provides the content of ‘a’ instead of address. This is due to overloading of ‘<<’ (you will learn more about overloading in OOPs). Hence we have to use explicit type conversion by doing this
cout<<(void*)&a;
This tells the compiler that the address is not required to be decoded to it’s respective content.
Is this a special type of typecasting , because I have never seen this pointer style of typecasting. I have seen type conversions like (int)a where a was a double datatype.
No, it’s just that it is used very less!
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.