Это видео недоступно.
Сожалеем об этом.
Singleton Design Pattern | C++ Example
HTML-код
- Опубликовано: 2 июн 2022
- How to implement the singleton design pattern in C++. This implementation is thread-safe and uses lazy instantiation. Source code: github.com/por.... Check out www.portfolioc... to build a portfolio that will impress employers!
Easy understand even for Juniors, thx MAN...
Very very well explained! Explained clearly and at an ideal speed of speech. It is very pleasant to listen to and you can directly comprehend the content conveyed. Thanks for the great video!
Thank you for sharing such kind positive feedback, and you're very welcome! 🙂
Great and well explained video. Thank your for your sharing. I hope you could add the rest of design patterns. It would be very helpful.
You’re welcome! :-) I do eventually want to cover more design patterns in C++.
I have checked out a lot of sources and channels but none of them explained as good as this one. can you by any chance make a data structures series in c++? it would be bomb!
I'm glad you enjoyed the video! :-) And hopefully one day I can do a data structures series in C++.
Your lessons are really brilliant! Short, terse, succinct with clear examples. Are you on Patreon?
good stuff Kevin!
Thanks Victor! 🙂
great job ❤
Thanks I’m glad you liked it! :-)
Great video. Are there any plans to do any more design pattern videos? I would love to see more
I would love to cover all the classic design patterns in C++ and Python. Exactly when I'll get to doing more, I'm not sure. :-) This video has started to get some great feedback and viewership over the last while though, which is really encouraging to make more design pattern videos.
Thanks bro
Thanks ❤ keep it up & plz post other important design patterns tooo
You’re welcome! :-) What other design patterns would you like to see covered?
@@PortfolioCourses decorator, command patterns and some important design patterns.. And Thanks for the response 🙌💫
@@CSEAJMALAKRAMS Thanks for the feedback! 🙂
Thanks for the video...it really helps.:)
You're welcome Rahul! :-)
Why make the constructor protected instead of private? I always made my singleton class constructors private and have had no issues. Maybe protected is doing something else I don't know?
Not really sure either, constructors aren't inherited so idk.
Hi sir from week I have been following your channel
Recently I come across why globally pointers allocate space in data segment in memory map..
Thanks for following the channel Rama. Is that a topic you think I should make a video on? Do you have a link to the article or video that you came across? :-)
I have a doubt acc to definition n code; the second creation of object singleton2 should not be correct or possible.
What is the reason we don’t get any such error?
Making the copy constructor a deleted function is what prevents the Singleton from being copied by using an assignment operator like this :Singleton singletonN = singleton1;. If the copy constructor is not a deleted function, then the assignment statement will be OK, and we will get a copy of the singleton using the default copy constructor.
Thank you 😊
You're welcome Manohar! 🙂
Hello, this is nice example, could you make one video? " Multiton pattern on C++"
That is a great idea for a video, I have added to my list of ideas. :-)
@@PortfolioCourses Ohhhh, thank you very much
@@osnovan7169 You're welcome! 🙂
best, though you hasn't explained the syntax in the multiple deleted operators
In videos on more advanced topics like this I don't always explain certain things due to time constrains. :-)
hey Kevin.
at 4:49, variable singleton1 is also a reference to a Singleton object. But get instance also returns a reference, so you returining a double reference at the end? Im getting kinda confused
The get_instance() function returns an instance, and singleton1 is an instance, so the types make sense. We're not returning a 'double reference' or anything like that.... get_instance() just returns a reference to that static instance variable and singleton1 will then become a reference (i.e. synonym) to that same variable. Reference variables definitely aren't straightforward, maybe this video will b useful: ruclips.net/video/e3DN1RaYVYQ/видео.html.
@@PortfolioCourses thanks master
Haha you’re welcome! :-)
What does "= default " do ?
It makes a defaulted function, this video explains the concept: ruclips.net/video/OupyUY7FKUI/видео.html. :-) There is also deleted functions too: ruclips.net/video/-PQRjsX_1i8/видео.html.
@@PortfolioCourses thanks - so default is used when NO Parameters are sent ?
In this example, yes.
Though this is a very minor point, technically what we pass the function are called "arguments". The "parameters" are the variables that those arguments are set to. So if we have:
void func(int x) { ... }
func(5);
Then x is the parameter and 5 is the argument.