Smart Pointer In C++
Vložit
- čas přidán 13. 09. 2024
- JOIN ME
-----
CZcams 🎬 / @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
DESCRIPTION:
In this video we will learn what is the actual use of smart pointers in c++.
It is basically a wrapper which wraps raw pointer and handles the life time of the object for you, means if there is no reference to the pointer it will delete it otherwise it will hold. There are basically three types of smart pointers.
TYPES:
1. unique_ptr
2. shared_ptr
3. weak_ptr
And the basic job of smart pointer is, it actually makes sure that we don't have memory leaks.
#stl #cpp #programming #tutorial #interviewquestions #softwareengineering #computerscience
Hi, I Have been learning CPP by your tutorials, your teaching is really good very understanding.
I would like to give a suggestion where please try to explain with symbol table and memory address mapping for all the videos you do.
Please who follows will get in-depth knowledge for sure.
Thanks
Great suggestion!
Will try!!
Finally I found a straight to the point nice explenation, thanks
Thanks..
Hello sir. Thank you very much for all the cppnuts video. I have gone through all of your uploaded cppnuts videos.Rearly all videos are very useful . I request you, could please upload the session on IPC and kernel level videos.
I would like to say…Thankyou Rupesh…Your video tutorials helped me crack my c++ interviews…I am a 11+ years experienced IT guy and it was difficult to crack interview at such experience with so much of technical c++ n advanced c++ questions…but you made it possible by putting variety of playlists with amazing explanations…so this channel is not just for freshers but experienced professional aa well to clear to in depth concepts in basic n advanced c++. Thanks alot again Rupesh for helping me out.
Waoo…
It feels good that I could contribute to some meaningful.
Thanks for such a wonderful comment.
All the best!! Rajesh Ranjan!!
@@CppNuts yes Rupesh…I cracked Technical Architect role cum Technical Project Manager interview for multiple companies 😊
Thanks alot again 🙏🏻
@@CppNuts The way you have explained how smart pointers work internally or how vectors actually work internally n many other concepts as well with so much clarity…we normally don’t get to see such content on everybody’s channel 😊
Thanks 😊
@@ranjanrajesh08Hi rajesh
Best channel for c++
Thanks man..
Perfect. Thanks for your effort and performance. It is pleasure to be here and watch your movies.
Thanks Dude, means a lot!!
You deserve to have more subscribers! Great job! Keep it up!
Sure...
Thanks man!!
Dem!
Literally, you have blown my mind!
This made me wonder how classes can be used for our advantage....
just yesterday, I was experimenting with pointers and was pretty disappointed by the fact that every 'new' must be paired with 'delete',
Now this smart pointer SOLVED this problem ! wahh
Glad to hear that!!
your all the series are very helpful, i always get to know something new here from others.
Thanks
This is a really good channel thank you for your videos! I like the fact that you also teach new c++ features from c++11 c++17 and so on. Most Videos just teach old C++98 shit and if you are a beginner you often get stuck because you dont know that there are easy features from c++11 onwards to help you with coding.
basically what is happening
:- if you create an object using new memory will be allocated in heap so that we have to call the delete for releasing the memory but here he is making the object of MyInt statically so the memory will be allocated in stack area and when the main function gets completed myint gets out of scoped and hence the destructor will be called.
Really very nice explanation.. you made it as a piece of cake.. Thank you so much..
Thanks dude...
An excellent, underrated channel.
Glad you think so!
Great explaination sir.thank you so much sir.
Hello CppNuts, I love your explanation on Smart pointers! Can I know your take on the pros and cons of using them?
Thank you so much sir I`m so grateful
Thanks Man!!
I really like the way you teach !!
I'm glad you like it
Awesome sir appreciate viedoe on smart pointer
Can you please provide the video on time and space complexity in data structures
Again tysm
good video sir,
can you please make video on r value reference move constructor?
sure..
Hi Rupesh sir, can you share an example to show how we can use smart pointers as templatized function pointer. This was asked in an interview.
Please make a video on noncopyable, what it is and why they are used? Thank you so much for your effort. I am enjoying your videos. Please continue making videos.
Noted, thanks..
As always, thanks bro
i couldnt understand unique pointer's usecase
like if we create multiple objects of a class (which holds a raw pointer), wont all of the objects point to differnt addresses in memory?
so whats the use of unique pointers?
Excellent explanation, but I believe it would be interesting if you can or want to subtitle your videos for a better understanding of the deaf and foreigners who do not speak English.
Sorry, that is some serious hard work, youtube should do it automatically.
It's hard for me to even find time to record a video.
I wish i could help in this matter.
Thanks for the suggestion.
Really great all videos on smart pointers. One request can you please upload a video on one of "C++11 Features Lamba Expression in details " . Please
Sure..
Nice explantation
Thanks and welcome
Hi Rupesh could you tell me what software do you use for the drawing and explanation (i think its a virtual whiteboard software but, which one). Great work on the tutorials dude!
Hi Ruesh,
Please explain why two times #ifdef #endif?
#ifdef __cplusplus
extern "C" {
#endif
/* Declarations of this file */
#ifdef __cplusplus
}
#endif
First one is to check if it is c plus plus file and second one is to complete the breaket we started while we wrote extern c.
@@CppNuts Thanks a lot
bro is this type of concepts asked from freshers//
although iam enjoying it but still
Yee it can be asked to freshers
finally.. awesome.
good explanation. :) the address is 1000,
Thanks 🙂
where i can get these programs?
Sir, here in main function int *p=new int(10); than we may use delete p here .....delete (data) will fine. isnt so?
Yes, and easy way to find is, if you see new in your program then corresponding delete also should be there, very easy way to track.
Hi Team,
May i know why we need to overload dereferencing operator ?
shouldn't it have been a templated class to be able to handle pointers of any type?
What role does explicit play in this role?
I did not use explicit for some special reason. Explicit is used only for the same reason it is used for normal cases also. Inferno what is the use of explicit keyword please Google it.
what's the use of explicit keyword ?
It is the regular use.
I have video for what is the use of explicit keyword.
i was searching for the 10000 :D
Can you create a Linux full tutorial, like IPC, shell script,etc..
Hi Rupesh,
What is the size of this pointer?
How to calculate the size of this pointer?
Every pointer size is 4 bytes in 32 bit system and 8 byte in 64 bit system
@@CppNuts But empty class size is 1 byte.
Why not 4 bytes if "this pointer" size is 4 bytes?
@@mdirshadalam2617 compile this code i have written for you, then you will understand better.
coliru.stacked-crooked.com/a/adfc493abd8abf08
Thanks
what is the use of explicit in constructor here?
explicit constructor In C++
czcams.com/video/j4iZ50lp9KM/video.html
Int & operator *() ; how to call this function and how it work could u explain me plz , thanks in advance sir
why constructor called explicit? and why default argument is passed as null to constuctor?
what will happnen if i write like below--
MyInt(int *p)
{
data = p;
}
can you please make note on constructor part here.
1 Why default is null: By doing that i made it default and copy constructor both at the same time (Its cool :D)
2 Why constructor explicit: So that no one is allowed to assign some pointer to MyInt class.
Example:
int k = 10;
MyInt i = &k; // wanted to stop this from happening
I hope you'll get it, if not then feel free to ask more questions :D
got it..thank you very much.
#include
using namespace std;
int* getStorage()
{
int* storage = new int[10];
return storage;
}
int main()
{
int* storage = getStorage();
for(int i=0;i
Int * storage() { int* storage
I believe here u should use unique ptr or shared as per ur requirement
You see
Example say fun() {
Int *ptr= new ptr(10) ;
Some condition
Return it
}
Say you are returning it in this function so if u won't use smart ptr(unique ptr) then it won't release the memory which has been allocated to this ptr
That's why u should use smart ptr
After using smart ptr
It won't be ur responsibility to release (delete) the memory used by ptr
Hope you get it
😃😃😃😃😃
can you provide the code in your github?
It's there
The person who donot subscribe to your channel will loose lot of practical programming knowledge.... 🙂
Very nice explanation, good effort, but please give up the fake american accent next time.
Thanks..
I can't 😂
I couldn't understand anything
:D :D :D
bro speak in indian endglish dont try to speak foreign english