My Rules of understanding pointers:- '&' - this will return an address of any variable or things. '*' - this will dereference an address 'int *' - this will make a pointer variable 'variable_name' - this will return value of a 'variable_name' Extra:- swap(a,b) - Call by value swap(&a,&b) - Call by reference
any data type with star will make a pointer variable which can be used to address a memory location containing data of same data type as pointer@@herohera3497
Hi everyone, I've created this updated video on POINTERS in C++: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-NwZL2UjHQZQ.html Do check it out. I'm sure you'll like it :)
*a++ karne se 2 hi aa rha he par *a += 1 karne se kaam de raha he aur 3 aa rha he, koi agar comment padh raha he to please bata do ye kyun ho raha he please.
@@ujjwalrockriser Dekho! Hum pointers address store karne ke liye use karte hai! So Jab tum address ko baghaoge i.e. *a++ karoge toh tumhara address next jagah par point karega jaha par kuch nahi hai. and jab tum *a+=1 karte ho tab address nahi increment hota hai, tab a par joh element hai usme 1 add hota hai! bcz jab hum *a++ karte hai tab memory address +2 se badhta hai, and jab hum *a+=1 karte hai tab woh element me 1 add hota hai. Samjhe?
@@ujjwalrockriser *a++ ki jagah (*a)++ try krke dekho, mera *a++ se nhi hua tha lekin brackets se kaam krgea,... ab bina brackets k kaam naah krne ka kaarn to meko bhi smjh nhi aaya, aapko smjh aaye to btaana
The point is we can't increment the pointer directly as *a++; It'll still print a=2 but using (*a)++; gives the incremented value It is somewhat similar to BODMAS rule. We need to dereference the pointer a then increment it Thank me later!
*a++ karne se 2 hi aa rha he par *a += 1 karne se kaam de raha he aur 3 aa rha he, koi agar comment padh raha he to please bata do ye kyun ho raha he please.
@@ujjwalrockriser are bro aisa isliye hai kyunki *a++ karne pe '++' operator ki precendence zyada hoti hai '*' se to vo address ka increment kar deta hai phir uss increased address ko dereference karta hai jisse apna original a same hi rehta hai iss issue ko solve karne ke liye apan ko bas (*a)++ ye likhna hai jisse pehle dereference ho phir increment
I don't know why people hate this kind of videos when someone is working so hard doing animation, writing the script, notes, editing the videos etc...etc... for your sake! Why can't we appreciate their work which has a huge impact on our society!!!
brother you are absolutely right, but also try to understand that if you are an absolute beginner, then did you understand? a big NO, so that's why some beginners didn't liking it!
a BIG Thanks to Aman SIr & there Team !! Such a Great Efforts for student's who can't afford colleges or classes without showing any add's between the video
In my opinion, you're the best teacher on Apna College! ( No offense to other teachers, everyone's doing a great job, it's just my personal opinion, I am a slow learner)
@@harshhingu3082 stock management, seminars in diff collages, affiliated marketing and much more... Our aman bhaiya is all rounder 😎 Their annual income is 7Cr (some plus students were discussing this in comments session)
The point is we can't increment the pointer directly as *a++; It'll still print a=2 but using (*a)++; gives the incremented value. *a++ - Post Increment Operator, it first assigns the value and then increases the value later on. If we use ++*a - Pre Increament Operator, then it increase the value first and then assigns the value later on. So on using ++(*a) will give you the correct answer. Thanks !!
If anyone is facing any problem, this can be because ++ has equal precedence with the * and the associativity is right-to-left. You can use ++*a or (*a)++ to specify the order of evaluation.
*Program to Increment variable using Pointers: #include using namespace std; void increment(int *x); int main() { int x = 2; increment(&x); //Pass by Reference cout
No you can't use *ptr = &a as it is different. In Int *ptr , *ptr is no a variable only ptr is a variable. U can also write it as int** ptr. Int* is not integer data type, it is a integer type data type for storing address of a int variable.
19:00 apne wnha addresses bheje hain pointer variable k is liy argument variable wnha pointer type k honge to accept the address coming from function call.
I apologize for any confusion, but the program you provided is an example of 'pass by address,' not 'pass by reference,' as it's important to use the correct terminology in programming.
One more easy Way to call #include using namespace std; void Swap(int &a,int &b){ int temp = a; a = b; b = temp; } int main(){ int a = 3, b = 5; Swap(a, b); cout
Program to Increment variable using Pointers:- #include using namespace std; void increment(int *a){ (*a)++; } int main(){ int a=2; increment(&a); cout
Hi everyone, I've created this updated video on POINTERS in C++: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-NwZL2UjHQZQ.html Do check it out. I'm sure you'll like it :)