What is the Difference Between a Pointer and a Reference C++

What is the Difference Between a Pointer and a Reference C++

Paul Programming

7 лет назад

418,625 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Chishiki endeavourer
Chishiki endeavourer - 17.11.2023 18:48

Great explanations. ❤

Ответить
Doctor MGL
Doctor MGL - 06.11.2023 02:56

we need 7 minute just to explain pointer and they still say c++ is easy to learn lol

Ответить
lakergirlHspics_M
lakergirlHspics_M - 03.11.2023 13:44

Suddenly! I feel that the pointer arithmetic is so easy😮
Thanks❤

Ответить
ka chun kwan
ka chun kwan - 20.10.2023 17:44

thank for your explaination

Ответить
Bhavya
Bhavya - 28.09.2023 21:36

ah so references to pointers as hard symbolic links are to soft symbolic links?

Ответить
my channel
my channel - 22.09.2023 01:35

OMG, how easy to understand. thank you

Ответить
jin choung
jin choung - 15.09.2023 10:05

way way way way way too wordy. just: "the address" "the thing at that address". that's it!

Ответить
Дмитрий
Дмитрий - 14.09.2023 07:11

Reference is... pointless.

Ответить
MoodyDood
MoodyDood - 23.08.2023 05:23

I suffered with pointers and references for close to a year, thanks a ton!

Ответить
social engineering
social engineering - 05.08.2023 16:16

Anyone from India?

Ответить
social engineering
social engineering - 05.08.2023 16:14

Thank you

Ответить
Hamza Benfaddoul
Hamza Benfaddoul - 09.07.2023 13:11

thanks, you are an amazing good explanation :) if you explain first how to assign the reference and the case that we can't do it with the reference and we can do it with a pointer it will be helpful

Ответить
Reza Hk
Reza Hk - 25.06.2023 20:41

His Tutorials are fantastic.
I don't know why he didn't continue uploading tutorials

Ответить
Weiqian Zhang
Weiqian Zhang - 23.06.2023 20:09

by far the clearest video I've found.

Ответить
Auntik Jeb
Auntik Jeb - 18.06.2023 07:13

You explained it so well i tried to understand the difference the whole day. Thank you🎉

Ответить
Rusty Spotted Cat
Rusty Spotted Cat - 17.06.2023 20:05

ref -> static mem.alloc (stack) vs ptr -> dynamic mem alloc (heap) && ref = substitute name (label) for address && ptr = variable holding address

Ответить
I_am_Dumb
I_am_Dumb - 27.05.2023 16:03

thankyou

Ответить
John Sindayen
John Sindayen - 23.05.2023 02:03

Here's the difference:
int v; //variable for primitive
int* pvti; //pointer variable to int
pvti=&v; //v has garbage, =address of v
cout<<*pvti; //dereferences primiti garbage
string rv; //reference variable for object
string* pvts; //pointer variable to string
pvts=&rv; //rv has garbage, =address of obj
cout<<*pvts; //dereferences objec garbage

Ответить
Alarii
Alarii - 21.05.2023 22:55

So a pointer is like a symbolic link and a reference is like a hard link?

Ответить
Axel Huaripata
Axel Huaripata - 12.05.2023 02:14

te amo loco, viva el conocimiento libre y a disposicion de todxs!!!!

Ответить
Noor Atal
Noor Atal - 11.05.2023 10:23

👍👍👍

Ответить
Reuben Chemmanam
Reuben Chemmanam - 10.05.2023 19:10

nice!

Ответить
Emre Yılmaz 2
Emre Yılmaz 2 - 09.05.2023 16:25

So why do we need the references while we can use pointers?

Ответить
Joël
Joël - 13.04.2023 15:57

Oke, but why? Why would a variable ever need 2 names?

Ответить
iVuDang
iVuDang - 02.04.2023 20:59

love the visualization, conciseness, and easy to follow style of this video , thank you

Ответить
Bharath kumar
Bharath kumar - 17.03.2023 19:39

Great

Ответить
Timo Epis
Timo Epis - 09.03.2023 20:47

I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you I love you . I can't say it enogh but I love you that you made it so simple!

Ответить
Christoffer Henriksen
Christoffer Henriksen - 28.02.2023 07:25

my problem isnt understading how it works, its more like... Why? why not just use the original variable?

Ответить
Andrew Taylor
Andrew Taylor - 26.02.2023 18:45

Paul your a mad dog thanks for this helped heaps

Ответить
Marouen Tebessi
Marouen Tebessi - 23.02.2023 17:17

vraiment très intéressant, mon connard professeur nous a rien expliqué

Ответить
BlackBlocky
BlackBlocky - 20.02.2023 06:01

Literally the best explanation of the pointers in all of coding history.

Ответить
bazoo513
bazoo513 - 18.02.2023 15:36

We haven't heard what's the purpose of references. It can't be mere aliasing, can it?

Ответить
Jnsee
Jnsee - 14.02.2023 19:43

thanks a lot, I really appreciate this explanation, it is done very well

Ответить
Mukesh Kumar
Mukesh Kumar - 14.02.2023 16:48

Thank you for this tutorial! It was clear, concise, and easy to follow.

Ответить
FxStreamer
FxStreamer - 02.02.2023 09:02

you oversimplified the difference between pointer and reference. its not created just because you would be able to change one and not to change the other one. pointing means you point to the thing in memory with regards of the type of the pointer. when it has a type it means it has a memory itself. whereas the reference means the absolute thing in that location . that makes difference when classes comes in the party.
Also the & is a function that return a memory address. And the * is a function that returns the value of a thing in a memory location.

Ответить
Iron Man
Iron Man - 31.01.2023 08:15

I have a confusion if reference is just another name for a variable and gives us the same value than why we just simply do
Int a,b;
int a=3;
Now just
int b=a;
Then b also gives us the same value
Why we need to make reference variable?

Ответить
adastraedu
adastraedu - 25.01.2023 17:53

Suggesting in an intro video that you should just assume that your pointer is initialized to 0 is just idiocy. You are starting off with a really bad habit. Why not just at least initialize to null, and say you did it, rather than lying? You aren't claiming to be using a global variable because you said it might be random.. Put it in main, say it's random, and initialize it.

Ответить
Andrew Taylor
Andrew Taylor - 09.01.2023 17:29

bro so easy and simple explanation, I got a friend who has 35 years in programming and he didn't make it easy to understand. Thanks again brother

Ответить
random account
random account - 02.01.2023 15:41

So the reference variable is literally like an alias for the actual variable since it doesn't even have its own address.

Ответить
baronvonmike
baronvonmike - 14.12.2022 22:19

Finally, someone just explains what an "alias" is.

Ответить
Black Coffee Development
Black Coffee Development - 10.12.2022 21:44

short, simple, and helpful. Thanks!

Ответить
Iyobosa Jefferson
Iyobosa Jefferson - 08.12.2022 16:09

Love how this was concise and diagrammatically explained.

Ответить
Thomas Sieber
Thomas Sieber - 29.11.2022 23:32

A pointer is an address in memory and stores at that address the address of an variable. A reference is just an address to the variable.

Ответить
Vive La Football
Vive La Football - 16.11.2022 18:43

Very nice explaination😍

Ответить
ZeniTGameS
ZeniTGameS - 16.11.2022 01:55

having c++ classes for 4 months, and i never had such a simple explanation between reference and pointers <3

Ответить
hasnaa
hasnaa - 13.11.2022 21:54

thank you so much that really helped !

Ответить
Diego Uribe
Diego Uribe - 24.10.2022 18:54

It's working thanks my friend

Ответить
Reinaldo Yang
Reinaldo Yang - 17.10.2022 20:11

Very good explanation! easy to understand

Ответить