Difference Between Reference And Pointers In C++

  Рет қаралды 65,282

CppNuts

CppNuts

Күн бұрын

JOIN ME
-----
KZbin 🎬 / @cppnuts
Patreon 🚀 / cppnuts
COMPLETE PLAYLIST
------------
C++ Tutorial For Beginners: • Introduction To C++
STL (Standard Template Library): • STL In C++
ThreadIng In C++: • Multithreading In C++
Data Structures: • Data Structure
Algorithms: • Binary Search
Design Patterns: • Factory Design Pattern...
Smart Pointers: • Smart Pointer In C++
C++14: • Digit Separator In C++
C++17: • std string_view in C++...
C++ All Type Casts: • static_cast In C++
INTERVIEW PLAYLIST
------------
C++ Interview Q&A: • Structural Padding & P...
C++ Interview Q&A For Experienced: • How delete[] Knows How...
Linked List Interview Questions: • Find Kth Node From Bac...
BST Interview Questions: • Search Element In Bina...
Array Interview Questions: • Reverse An Array
String Interview Questions: • Check String Is Palind...
Bit Manipulation Questions: • Find Set Bit In Intege...
Binary Tree Interview Question: • Invert Binary Tree
Sorting Algorithms: • Bubble Sort
C++ MCQ: • Video
C MCQ: • What printf returns af...
C Interview Questions: • Designated Initializat...
QUICK SHORT VIDEOS
-------------
C++ Short : • C++ Short Videos
C Short : • Shorts C Programming MCQ
As the title say there is very big difference between reference and pointer in c++. So lets learn them and do comment if you have any question about the video.
#cpp #tutorial #interviewquestions #computerscience #softwareengineering

Пікірлер: 65
@CppNuts
@CppNuts 5 жыл бұрын
Hi everyone, Don't forget to hit LIKE and SUBSCRIBE button for more videos like this!! And this will help me a-lot.
@IshaqKhan-rk5bl
@IshaqKhan-rk5bl 6 жыл бұрын
i have seen many channels regarding c++ but your content is to the point and also that extra knowledge about things is amazing
@CppNuts
@CppNuts 6 жыл бұрын
Thanks dude.. :)
@jonathanmoore5619
@jonathanmoore5619 3 жыл бұрын
Great video.
@CppNuts
@CppNuts 3 жыл бұрын
Thanks man..
@subratkumarsahoo3633
@subratkumarsahoo3633 5 жыл бұрын
Reference can extend the lifetime of a temporary object. In C++ if you bind a const reference to a temporary object, the lifetime of that object becomes the lifetime of the reference.
@kushgh
@kushgh Жыл бұрын
I absolutely love your videos Cpp Nuts. If it weren't for you guys, I would have never learned MultiThreading so fast. I just wanted to point out that at 07:00 - You mention that r++ is impossible and (&r)++ is possible, whereas its the opposite. You will get the following error at (&r)++ -> error: increment of read-only location ‘& r’ Whereas r++ will just increment i by 1, so i and r will become 11. Love your content. And a major salute to Team CppNuts.
@fatihersoy7559
@fatihersoy7559 4 жыл бұрын
Best cpp lecturer on KZbin.
@CppNuts
@CppNuts 4 жыл бұрын
Thanks man..
@somanathnayak4279
@somanathnayak4279 6 жыл бұрын
Hi, Thanks a lot for your noble effort of adding cpp videos. I have a question. Please let me know when to use only pointer and when to use only reference while writing a program. What is the real life usage of reference over pointer? If reference and pointer both are present in C++ means there should be some situations where only reference is useful and some places where only pointer is useful. Thanks in advance.
@prishaphotography9063
@prishaphotography9063 7 жыл бұрын
Sir,you covered more than expected content.might be you are the only one
@CppNuts
@CppNuts 7 жыл бұрын
+Ankit Makadia thanks man.. :)
@seriouss9077
@seriouss9077 4 ай бұрын
Also we cannot increment and decrement value of refrence as mention in video
@kartikpodugu
@kartikpodugu Жыл бұрын
Can you elaborate what is the use of creating a reference to a reference ?
@seriouss9077
@seriouss9077 4 ай бұрын
1:29 4:43 5:31
@georgeabraham7256
@georgeabraham7256 2 жыл бұрын
&: you can make a copy or pass a reference, you need to have an independent copy(y = x) that will change from the original or you need to modify the same source value somewhere else(&y = x). *: you need to index something, even the CPU indexes it's instruction code and registers incrementors through your program with the same feature gained from a pointer.. anything can be indexed... the heap is only accessible by registers tracking your stuff on the heap by address values stored in the stack by hard design.. you can't get past the extra *dereference to gain access to the stuff you have out there. stack: a memory address containing a value, heap: a memory address containing a memory address that containing a value/structure/etc.
@nithyanarayan8080
@nithyanarayan8080 6 жыл бұрын
Nice video. Having a doubt in indirection: Can we consider this as multiple indirection? int i=1; int &r=i; int &j=r; int &e=j; int &m=e; cout
@BiranchiNarayanNayak
@BiranchiNarayanNayak 2 жыл бұрын
Excellent Explanation, love it
@CppNuts
@CppNuts 2 жыл бұрын
Thanks
@cos1paY
@cos1paY 5 жыл бұрын
Very helpful. thx
@CppNuts
@CppNuts 5 жыл бұрын
glad it helped.
@srinivas2808
@srinivas2808 7 жыл бұрын
plz make a video of difference b/w function overloading and overriding ......
@CppNuts
@CppNuts 7 жыл бұрын
+Srinivas KL, here is that video, what you asked for kzbin.info/www/bejne/eZW5oZWge8qnepo
@srinivas2808
@srinivas2808 7 жыл бұрын
Thank you .....
@CppNuts
@CppNuts 7 жыл бұрын
+Srinivas KL you are most welcome :)
@JacobMartin-l1f
@JacobMartin-l1f 2 жыл бұрын
I do not see how someone deem this a good and precise explanation. Thanks for removing dislike, KZbin broncos.
@CppNuts
@CppNuts 2 жыл бұрын
I appreciate that!
@spicytuna08
@spicytuna08 6 жыл бұрын
hold on. if p is a pointer to an int. int *p; int i = 10 p=i; *p is 10. p is the address of i.&p is the adress of p. is this correct?
@CppNuts
@CppNuts 6 жыл бұрын
Yes correct but assume mean to say p=&i; in your comment then everything you wrote is valid.
@esmaeil9478
@esmaeil9478 5 ай бұрын
Thank you!
@adityaghaywat3648
@adityaghaywat3648 4 жыл бұрын
@3:25 why it is different?
@lidavid7809
@lidavid7809 3 жыл бұрын
really clear, thank u sir!
@CppNuts
@CppNuts 3 жыл бұрын
Glad it helped!
@MrDhawal29
@MrDhawal29 7 жыл бұрын
Your Regular follower now..:D Prepare a video on Red Black tree in DS.. And yeah keep it up !!
@CppNuts
@CppNuts 7 жыл бұрын
Hi Dhawal Arora, Let the data structures & algorithms turn come. :D I am trying my best to reach that list ASAP, and thanks for following my videos dude.
@MrDhawal29
@MrDhawal29 7 жыл бұрын
No worries dude,Keep it up..we are with you !!
@CppNuts
@CppNuts 7 жыл бұрын
+Dhawal Arora, thanks dude..
@सत्यमेवजयते-स7प
@सत्यमेवजयते-स7प Жыл бұрын
I think you missed 1 poimt which that we cannot have array of references but with pointers it is possible
@CppNuts
@CppNuts Жыл бұрын
Oh.. great.. Thanks for pointing this out. I should pin this comment so that few people would get benefited from this comment.
@Ady2xp
@Ady2xp 7 жыл бұрын
Awesome video! Thank you for it!
@CppNuts
@CppNuts 7 жыл бұрын
Ady2xp, thank you so much.
@sathviktumoju1195
@sathviktumoju1195 4 жыл бұрын
good work
@CppNuts
@CppNuts 4 жыл бұрын
Thank you! Cheers!
@kroax9720
@kroax9720 3 ай бұрын
Nice content , but mate switched accents in between the video !
@kinjalshah2796
@kinjalshah2796 4 жыл бұрын
How members are accessed through reference?
@akshaykulkarni1301
@akshaykulkarni1301 3 жыл бұрын
Thanks
@CppNuts
@CppNuts 3 жыл бұрын
Welcome
@rakhilsoman9299
@rakhilsoman9299 6 жыл бұрын
at 6:58 You say (&r)++;. This is an error, right?
@pardeepbhatt9048
@pardeepbhatt9048 6 жыл бұрын
right
@spicytuna08
@spicytuna08 6 жыл бұрын
hold on. reference variable must occupy a space somewhere. i get it that it is an alias. but there must be a space for alias.
@sakuranooka
@sakuranooka 3 жыл бұрын
Ok, I can see all these differences. But what is actually the purposes of references? Why did people decide to introduce them? To me references look like synonyms for variable names, so I can use "r" instead of "i", but what's the point? Why SHOULD I use "r" rather than "i"?
@reassume4826
@reassume4826 2 жыл бұрын
Suppose u want to have another variable with the same value...so to keep the other variable update and also reuse the memory of previous variable..we just store references.
@LazyTechNo
@LazyTechNo 6 жыл бұрын
u said reassignment is not possible with reference. then u put r = var and accepted that how its possible then ? i didn't get this point watching 2 times. please explain
@CppNuts
@CppNuts 6 жыл бұрын
I would have said that once reference is pointing to something, then we can not change it to refer something else. And when you are creating reference that time only you have to initialize to which it should refer. And then it will not change what it is referring to. And you can not just create reference variable without making it refer something.
@LazyTechNo
@LazyTechNo 6 жыл бұрын
i am also saying that &r = i; which is pointing to something. then how u changed r = var; ?
@CppNuts
@CppNuts 6 жыл бұрын
Actually you are not changing the reference, you are changing the value at i with var.
@zc4060
@zc4060 5 жыл бұрын
int a = 10; int *p = &a; p and a should have the same address. I tried it on my computer.
@CppNuts
@CppNuts 5 жыл бұрын
p is holding the address of a, but p will have its own address, then only p can store the address of a right?? if(p == &a) is true
@spaceinvader8892
@spaceinvader8892 5 жыл бұрын
Nice, but I would write Address Arithmetic Operations for 4th.
@bluehornet6752
@bluehornet6752 7 жыл бұрын
You talk WAY too fast in the beginning of your videos. It's virtually impossible to understand what you're actually saying. Otherwise, it was a nice video and a good review of references compared to pointers in C++. I might have made use of *nullptr* instead of NULL for initializing the pointer, but that's not a huge deal. It's just the new C++.
@CppNuts
@CppNuts 7 жыл бұрын
Tom B, i will work on my speed, thanks man.. :)
@Vickyrd7936
@Vickyrd7936 3 жыл бұрын
All your viideos are awesome. Only thing hurts to (my) ears are your fake accent.
@CppNuts
@CppNuts 3 жыл бұрын
😂
@HosseinAmirshaghaghi
@HosseinAmirshaghaghi 2 жыл бұрын
That is not a good explanation.
@CppNuts
@CppNuts 2 жыл бұрын
What happened?
static_cast In C++
15:37
CppNuts
Рет қаралды 94 М.
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН
AI is Like Chess
1:40
Data Products
Рет қаралды 58
you will never ask about pointers again after watching this video
8:03
C++ Pointers - Finally Understand Pointers
15:56
Caleb Curry
Рет қаралды 223 М.
Weak Pointers in C++ (std::weak_ptr)
17:25
The Cherno
Рет қаралды 63 М.
Pointers and dynamic memory - stack vs heap
17:26
mycodeschool
Рет қаралды 1,5 МЛН
The Difference Between Plain Enum And Enum Class In C++?
10:08
what even is a "reference"?
5:44
Low Level
Рет қаралды 146 М.
References in C++ Explained
14:21
Caleb Curry
Рет қаралды 105 М.
String In Char Array VS. Pointer To String Literal | C Programming Tutorial
9:58
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН