VERY helpful vid, just a small error though, you ended up changing ptr2 into address of y as well at 7:12 other then that, good job, so much clearer then my lectures.
you'll understand better when you use libraries.Ex: if you need to change the content of a variable in a function and you want to "save" the changes that you made on that variable, you can't avoid using pointers. Ex: void Change(int x) { x = 5 ; } int main() { int MyNumber = 12; Change( MyNumber ); cout<< MyNumber; return 0; } you'll notice that MyNumber didn't change and it's still equals to 12. try it yourself and try to figure out how to fix this problem, post your solution here ;) see you.
As far as i've learned, using a pointer IS passing by reference.
If you mean using references to pass by reference, then you could do that, but a reference can only point to one address where as a pointer can be changed to point to a different address if you want.
@simplcool As its been 9 months, ill solve it for him. Instead of passing a copy of the argument, you should pass a reference (an address) that the value is stored at. In C++, we use the ampersand to do that. void Change(int &x) { x = 5 ; } int main() { int MyNumber = 12; Change( &MyNumber ); cout<< MyNumber; return 0; }
Nice tutorial! Visual tutorials help a lot!
AlecGirman 1 month ago
Great video! First video I have seen to clearly illustrate what pointers really IS! THANK YOU!
dagjomar 1 month ago
thank u :)
theevilrapist 2 months ago
What a boss, I want this guy to lecture me :D
fr00tcrunchStarcraft 2 months ago
Very Impressive...
Thanx a lot :)
TheMrkamlan 7 months ago
thanks for your help, this is one of the more difficult concepts to understand in programming
DIEaHEROdotNET 8 months ago
thanks..i skipped programming and now i need to learn these:)
ioanjivan 11 months ago
thanx its realy help me
MrMuaz12 1 year ago
y he always say "start" ? it is star * not start :D
evgenii0 1 year ago
thnx you very much man
mrsaladinoo 1 year ago
VERY helpful vid, just a small error though, you ended up changing ptr2 into address of y as well at 7:12 other then that, good job, so much clearer then my lectures.
emp3ria 1 year ago
How can Y be a interger I thought interger means numbers?? im confusedO_O
MrOnix9009 2 years ago
@MrOnix9009 y is the name of the integer. its just like algebra
y+x=3
y = 1
x= 2
x and y are both integers, the lettersjust represent numbers
xkeltoix 2 years ago
This is so confusing O_o
MrOnix9009 2 years ago
How come you don't name the & amperand.
ponit54 2 years ago
thanks!
topinaburs 2 years ago
whats the difference of making the '*' to the type or to the variable? i mean:
int* ptr;
int *ptr;
Thanks!
exilePerformance 2 years ago
No difference.
aharnam 2 years ago 2
@exilePerformance no difference just your preference actually
ANXIOUS117 1 year ago
this helped alot thnx man ! ! now i know how to use pointers but i still don't know why do we use em !!
xbadnerd18x 2 years ago
simplcool 2 years ago 2
You could just pass by reference and eliminate the use of a pointer.
netsoj 2 years ago
As far as i've learned, using a pointer IS passing by reference.
If you mean using references to pass by reference, then you could do that, but a reference can only point to one address where as a pointer can be changed to point to a different address if you want.
At least, thats what iv learned so far.
sorry if im wrong.
Smito0 2 years ago
FOOFlGHTERS 1 year ago 2
@FOOFlGHTERS Wont works, returns an error message : Invalid initialization of non-const reference of type int& from a temporary of type int*
In passing argument 1 of void Change(int&)
LtuL1 1 year ago
@FOOFlGHTERS The right solution would have been :
void change( int* a) {
*a= 5;
}
int main() {
myNumber=12;
change(&myNumber);
cout<<myNumber;
}
LtuL1 1 year ago
@simplcool cant you simply just pass x by reference?
srb123ism 3 weeks ago
this is the clearest explanation ever. thanks very much
vanlinx 2 years ago 2
that table really helped, if only i was taught like that from the beginning.
exidezz 2 years ago
This has been flagged as spam show
Check out my video on pointers.
0121ryanh117 2 years ago
very well explained, at last I understand pointers now :) thx for the help ! keep more tutorials coming!
Yaga19 2 years ago
thanks for making this; helped me a lot
yellowmoe 2 years ago
Thanks, I haven't been able to get my head around pointers up till now
funkyewan 2 years ago
Thanks dude this has helped with my work a lot cheers
willyk56 3 years ago
Very well explained, thanks.
chirurulez 3 years ago
Thanks! This helped me alot :-)
xmotos250 3 years ago
Great vid d00d!
netsoj 3 years ago
pretty helpfull thanks
backLASH537 3 years ago
this totrial really helped me
thanx alot :)
3inawyah 3 years ago
Thank you the was very helpful, can you please put more video.
convoicon118 3 years ago