Singleton Design Pattern In C++

Поделиться
HTML-код
  • Опубликовано: 25 окт 2024

Комментарии • 153

  • @CppNuts
    @CppNuts  5 лет назад +7

    Hi everyone, Don't forget to hit LIKE and SUBSCRIBE button for more videos like this!!
    And this will help me a-lot.

    • @CppNuts
      @CppNuts  4 года назад +1

      Sorry for that..

    • @aseemsameer7281
      @aseemsameer7281 2 года назад

      You're leaking the memory assigned to _instance. You have to mention how you will free the singleton class object. It cannot be done with the destructor, is a very important point.
      All in all, the explanation is haphazard.
      The explanation is acceptable for a newbie. From interview perspective for a skilled professional, the interviewers will reject the candidate within a moment.

  • @spicytuna08
    @spicytuna08 6 лет назад +1

    i am addicted to your videos. i am a Cppjunkie.

  • @okbazoueghui6590
    @okbazoueghui6590 5 лет назад +13

    Great video! however, you have a memory leak as you didn’t free the pointer at the end of the program. This design is error prone as it relies on the user to free the pointer. To solve the problem you might use a shared pointer instead of a raw pointer.

    • @CppNuts
      @CppNuts  5 лет назад +4

      Yes you are correct.

  • @venugopalreddygopu315
    @venugopalreddygopu315 7 лет назад +3

    Thanks for video. Can you please help me with below questions.
    1. I don't see destructor in your video. Do we really need a destructor in Singleton pattern ?
    2. Can we implement reference counting mechanism in singleton. If so please share the use case/example. I think destructor should have role here.

    • @CppNuts
      @CppNuts  7 лет назад +8

      Hi venugopalreddy gopu, Nice questions.
      1. You can keep destructor in singleton but you know one implements destructors for types which gets created and die in between your programs life[start-end], but singleton gets created in your program some where doesn't matter but stays there for ever till your program is running.
      And here comes the real fun with memory leak thing: When your program goes out of scope most probably all OS (Windows, Linux, Solaris..) keeps track of all the memory allocated to a process, and will free it when that process terminates, this was just for your knowledge i am not encouraging NO destructor singleton implementation :D.
      2. I think no need to count reference because you should not make any copy of singleton object, that is what this singleton thing is all about.(always get the fresh object by calling static method of singleton class), because if you will keep copies then which one is the original one?
      Reason for creating singleton is: There is a requirement that we need to have only one object of that type throughout our program and if anyone wan't to change they will change that single object. (That single object will work as global data to your program)
      Please ask if any question.
      And i think i should upload singleton with more clear picture and keep destructor and private constructors, i missed in this video, i apologies for that.

  • @shahidchVlogs
    @shahidchVlogs 2 года назад

    what a great way of teaching thank you sir for this wonderful helping video for my exams preparation.

    • @CppNuts
      @CppNuts  2 года назад

      Glad could help.

  • @arjunudagatti6843
    @arjunudagatti6843 6 лет назад +2

    Very well explained!!
    Couple of things I have observed:
    1). Copy and assignment operator not mentioned under private section.
    2) Source code link not found in the description section.
    Thanks in advance!!

    • @CppNuts
      @CppNuts  6 лет назад

      Thanks for pointing out that man. like is updated.. :)

  • @santoshsco
    @santoshsco Год назад

    superb explanation of the design pattern .

  • @Saurabh2816
    @Saurabh2816 4 года назад +3

    Source code with some variations.
    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include
    using namespace std;
    class GameSetting {
    private:
    static GameSetting* _instance;
    int _brightness;
    int _width;
    int _height;
    GameSetting(): _width(567), _height(34), _brightness(53) {} // constructor is private
    public:
    static GameSetting* getInstance() { // static function
    if(_instance==NULL)
    _instance = new GameSetting();
    return _instance;
    }
    int get_brightness() {
    return _brightness;
    }
    int get_width() {
    return _width;
    }
    int get_height() {
    return _height;
    }
    void set_brightness(int _brightness) {
    this->_brightness = _brightness;
    }
    void set_width(int _width) {
    this->_width = _width;
    }
    void set_height(int _height) {
    this->_height = _height;
    }
    void display() {
    cout

  • @benoitbrisson6483
    @benoitbrisson6483 2 года назад

    Really great video!
    More, all your videos are really good!.
    All your videos goes straight to to point.
    Why so little people have liked your video?

    • @CppNuts
      @CppNuts  2 года назад

      Thanks dude..

  • @KanishkaDutta
    @KanishkaDutta 7 лет назад +1

    Really good video. I was searching for a good design patterns video lecture for months. Keep uploading more.

    • @CppNuts
      @CppNuts  7 лет назад

      Thanks.. glad could help..

  • @alexandergaran2924
    @alexandergaran2924 2 года назад

    Спасибо, все понял. Смотрел видео от своих соотечественников - ничего не понял. Языка английского не знаю, но этого парня понял лучше, чем рускоязычного.

  • @sathellipriyanka4600
    @sathellipriyanka4600 5 лет назад +1

    Superb sir....I must say u have awesome teaching skills

  • @janardhanreddy6846
    @janardhanreddy6846 4 года назад +1

    your explanations are simply awesome bro...

    • @CppNuts
      @CppNuts  4 года назад

      Thanks bro..

  • @sivaramakrishnachitithoti1428
    @sivaramakrishnachitithoti1428 3 года назад

    Thanks roopesh. I always respect your explanations 👋.

    • @CppNuts
      @CppNuts  3 года назад

      Thanks man..

  • @sallaklamhayyen9876
    @sallaklamhayyen9876 2 года назад

    Great explanation thank you so much
    but you forgot to delete the pointer

    • @CppNuts
      @CppNuts  2 года назад

      Yes, you are right.

  • @viethathai7025
    @viethathai7025 4 года назад

    Thanks you ! This video actually help me a lot ! Keep going

    • @CppNuts
      @CppNuts  4 года назад

      Glad it helped!

  • @marshallsweatherhiking1820
    @marshallsweatherhiking1820 Год назад

    I don’t know if this is standard practice but sometimes my singleton loads a bunch of data into memory, but I want it to load when needed as opposed to when the program starts. I have all the data in a std::unique_ptr member (normal variable, not static) that points to a struct. I have isLoaded() that returns true whenever the pointer isn’t null and a load() that gets automatically called by getInstance() e.g.
    If ( ! isLoaded() ) load();
    Then I just have a freeMemory() static function that gets called by a separate garbage collector class that calls the equivalent function for every singleton of this type in my program.

  • @amitvlogs536
    @amitvlogs536 4 года назад +1

    Nicely explained Rupesh thanks a lot. Also your all other videos I see from long time and it helps a lot . Also can you make video on thread safe singleton design pattern.

    • @CppNuts
      @CppNuts  4 года назад

      Sure dude..
      Other people are also asking for it.

    • @amitvlogs536
      @amitvlogs536 4 года назад

      @@CppNuts thanks....

  • @swapnilkushwah8974
    @swapnilkushwah8974 3 года назад

    Just wanted to know where we are deleting the instance which we made in the static function?

  • @deepaksingh-mk2nu
    @deepaksingh-mk2nu 6 лет назад +2

    Hi you are doing great jobbb........................Please make some video on Multithreading ..........

    • @CppNuts
      @CppNuts  6 лет назад

      sure dude wait for some time..

  • @AjitV
    @AjitV 4 года назад

    Question :
    _instance is a private member, how come you are able to allocate memory directly ?
    or
    Is the access specifier nullified if its a static member / function in a class ?

  • @Gautamdange
    @Gautamdange 5 лет назад +1

    nice video .. !
    Game setting .. Hotkeys setting is good example.

    • @CppNuts
      @CppNuts  5 лет назад

      Thanks man 😊

  • @biswaranjan3550
    @biswaranjan3550 7 лет назад

    Hi,I have one doubt why we are returning class pointer type for both the static member variable and static method .Could you please clarify my doubt. Thanks in advance...

  • @MrSravan21
    @MrSravan21 6 лет назад +1

    Thanks a lot,by seeing ur video got clear understanding over singleton design pattern.

  • @ajaylearningcentre8898
    @ajaylearningcentre8898 2 года назад

    Hello sir.. r u a software engineer in c++... u r following naming conventions... would u please explain how to follow naming conventions in c++

  • @HARSHITSINGH-jf7ff
    @HARSHITSINGH-jf7ff Год назад

    what is static methods? Purpose of using it?

  • @spicytuna08
    @spicytuna08 6 лет назад

    _instance being a private member and a static at the same time seem to be conflicting to each other. The fact that you can assign a value of nullptr to it directly seems to be conflicting the private access modifier. In this case, it doesn't matter whether or not it is a private.

  • @андрейгорничар
    @андрейгорничар 3 года назад

    the video is great , but be careful with heap , you forgоt a delete operator . please be careful or use smart pointers

    • @CppNuts
      @CppNuts  3 года назад

      I am planning to create new video, i did so many mistakes in this.

  • @vipulmendapara8754
    @vipulmendapara8754 7 лет назад +5

    you did not add copy constructor and assignment operator in private area. is it intentional?

    • @CppNuts
      @CppNuts  7 лет назад +1

      just forgot to mention that.. thanks for informing.

    • @snehashishpaul2740
      @snehashishpaul2740 7 лет назад +1

      But why do we need a copy constructor and assignment operator? We are dealing with class pointers only and the real purpose of singleton DP was to have only one instance with client not getting any real handle to create objects, instead it is getting pointer to an object created only once.
      Correct me if I am wrong..

    • @CppNuts
      @CppNuts  7 лет назад +1

      snehashish paul Hi..
      You are right, we don't need them that is the reason vipul mendapara, asked me why did i forgot to include them in private section, because if will not move them in private section then compiler generated copy constructors and assignment operator will be in public section and they would allow your object to get copied.

    • @snehashishpaul2740
      @snehashishpaul2740 7 лет назад +1

      ok, great.. Thanks to you for starting this C++ series.

    • @CppNuts
      @CppNuts  7 лет назад

      snehashish paul Hi..
      glad you liked it.

  • @abhinavpathak9922
    @abhinavpathak9922 6 лет назад +1

    Sir please explain threadpool in detail will be very grateful to u .
    Thankyou for explaination sir

  • @TechSafarWithSunil
    @TechSafarWithSunil 7 лет назад +2

    Need some explanationa on object pooling and thread pooling.
    At the end of program can i use this code:-
    delete GameSetting::getInstance();

    • @CppNuts
      @CppNuts  7 лет назад +2

      +sunil singh hi..
      very nice question, assume there is pool of objects which contains already built objects when your program needs any object then it will take from that pool and once done will return that object to the pool.
      And same for thread pool there you will have threads in the pool.
      if you need some thread take it from the pool and once done with thread return to the pool.
      And one thing which you might be knowing... that we create pool of those things which is valuable resource and creating them will take long time. so if you will keep a pool of such things and when ever needed you take it from there but don't destroy after using it, simply keep it in pool next time when needed dont create again just take it from the pool..
      hope helped !!

  • @bittupandey6645
    @bittupandey6645 3 года назад

    we need copy constructor too? correct me if I am missing something here

    • @CppNuts
      @CppNuts  3 года назад

      No, it should be private or assigned with delete.

  • @Jerry-qm4fl
    @Jerry-qm4fl 3 года назад

    Excellent, Thank you very much.

    • @CppNuts
      @CppNuts  3 года назад

      Glad it was helpful!

  • @sriraamm5008
    @sriraamm5008 7 лет назад +1

    Thank You for the clear explanation ... :)

    • @CppNuts
      @CppNuts  7 лет назад +1

      +Sriraam M hi...
      you are welcome.. :)

  • @aswinvenugopal1929
    @aswinvenugopal1929 4 года назад

    Suppose, I have a friend class to the singleton class. By friends property, it will be able to access the private data members and functions. So it will be able to access the private constructor and thereby new object instantiation might be possible. Is there any way to block this way of object instantiation as it defeats the total concepts of singleton design pattern. Expecting a reply if the question is relevant.
    Thanks in advance.

  • @rishabhjaishwal1247
    @rishabhjaishwal1247 Год назад

    may be you should need to print address to show object is not created again. And by the way video is still worth it.

  • @habibyama
    @habibyama 6 лет назад +1

    Thanks a lot. You have got very good explanation skills. Amazing job.

    • @CppNuts
      @CppNuts  6 лет назад

      Thank you so much..

  • @pravinmote1906
    @pravinmote1906 4 года назад +1

    Need to delete the copy constructor. Otherwise the singleton instance can be copy initialized

  • @soumyasambitkunda
    @soumyasambitkunda 3 года назад

    Do not we need private assignent operator and copy constructor for a singleton Class?

    • @CppNuts
      @CppNuts  3 года назад +1

      Yes we need that..

  • @spicytuna08
    @spicytuna08 6 лет назад +2

    in C++, is there a way to check if this is the same object? hey, i have to say it was pretty impressive when you were able tp compile and run in one try. maestro. make me a maestro.

  • @amitpaunikar3408
    @amitpaunikar3408 5 лет назад +1

    Good video..... Sir Please make a thread safe singleton pattern c++ video.

    • @CppNuts
      @CppNuts  5 лет назад +1

      Sure dude..

    • @amargandhi1137
      @amargandhi1137 5 лет назад +1

      Plz sir make the videos on thread safe

  • @akashraut2550
    @akashraut2550 7 лет назад +1

    nice video with good example keep it up .

  • @BrunoFPcovers
    @BrunoFPcovers 5 лет назад +3

    Thank you very much. Lord save you.

  • @abhishekkaushick1
    @abhishekkaushick1 6 лет назад

    Global access and ownership, it may be disadvantage because anyone can modify, right?

  • @rahulr9301
    @rahulr9301 3 года назад

    I see difference in your voice:) but not in teaching style its great

  • @spicytuna08
    @spicytuna08 6 лет назад

    i see this pattern as a global variable. its a fancy way of saying global variable. is this one object per session or one object across all sessions? lets say 100 users log into FB. all these users have one instance of DB connection and one instance of log obj?

  • @abhideka
    @abhideka 3 года назад

    You forgot to put copy ctor and assignment operator in the singleton class design. Or, to avoid memory leak you can add move ctor and move assignment operator.

  • @sriraamm5008
    @sriraamm5008 7 лет назад

    What is the actual reason behind defining the static variable *instance outside the class, I tried to define *instance = NULL inside the class where it is declared but returns error...

    • @CppNuts
      @CppNuts  7 лет назад +1

      ruclips.net/video/EZMJmr3HVC8/видео.html
      you will get your answer here.

  • @pitrya2533
    @pitrya2533 Год назад

    Looks like addresses of both the setting objects are different.

  • @navyareddyvarikuti2647
    @navyareddyvarikuti2647 6 лет назад +1

    You forgot to explain about Lazy Initialization in singleton. can you please explain w.r.t to code?

    • @CppNuts
      @CppNuts  6 лет назад +1

      It is already lazy initialization. In getInstance() function we are creating object, this object will never be created until it is needed or to say until getInstance() is not called. (this concept is call lazy initialization)

    • @navyareddyvarikuti2647
      @navyareddyvarikuti2647 6 лет назад +2

      Thank you.. understood clearly. One help! kindly make video on virtual function with diagrams using vtable and vptr w.r.t code in c++

    • @CppNuts
      @CppNuts  6 лет назад

      sure will do it..

    • @soumyasambitkunda
      @soumyasambitkunda 3 года назад

      @@CppNuts Still waiting for this video.

  • @ajayjadhav900
    @ajayjadhav900 4 года назад +1

    i need a code but when i go through code link, its something else.please help i have study other patterns as ell this is first one

    • @CppNuts
      @CppNuts  4 года назад +1

      Here you will get all.
      github.com/7yadavrupesh/designpattern?files=1

  • @HARSHITSINGH-jf7ff
    @HARSHITSINGH-jf7ff Год назад

    Thread pool not understood please share a useful link.

  • @shishirchaurasiya7374
    @shishirchaurasiya7374 10 месяцев назад

    Why the object is not created using new keyboard

  • @jomonpaul3640
    @jomonpaul3640 5 лет назад +2

    Can u share link for source code. I can't get source code from above mentioned link

  • @iaavash
    @iaavash 5 лет назад +1

    Bro which Linux distro are u using????

    • @CppNuts
      @CppNuts  5 лет назад

      Hi it is kubuntu 12.

  • @mihirsevak4456
    @mihirsevak4456 7 лет назад

    You definitely know this design pattern. May be you can do better explaining it. If you took two or three examples to explain it that would have been better. Take one case of multi threading take one database case. I am not really convinced you need only one connection instance to database. What if I need to update database once every four hours? Why would I keep an instance around? You can argue with me here on it if you want.
    Thanks.

    • @CppNuts
      @CppNuts  7 лет назад

      Interesting comment,
      answer for data base question: we keep data base instance one to avoid race condition.
      i will upload multi-threading example some day for sure..
      and plz do comment if you have any difficulty to understand part of the video.

  • @afifkhalid6703
    @afifkhalid6703 3 года назад

    Can these slides are available?

  • @orangasli2943
    @orangasli2943 2 года назад

    You don't delete the pointer?

    • @CppNuts
      @CppNuts  2 года назад

      Yaa that’s a mistake.

  • @bittupandey6645
    @bittupandey6645 3 года назад

    nice one !!

  • @avtarchandra2407
    @avtarchandra2407 2 года назад +1

    Videos please ..... nowadays you are not uploading videos

    • @CppNuts
      @CppNuts  2 года назад

      I am in my hometown, and things are not in my favor.
      Going back to Banglore on 7th then you will see new videos.

  • @abhijeetoshin1629
    @abhijeetoshin1629 7 лет назад +1

    can u make a good program on inheritance

    • @CppNuts
      @CppNuts  7 лет назад

      Working on C++ Programming Series, will be available soon.

  • @sonulohani
    @sonulohani 7 лет назад +9

    Use nullptr instead of NULL

    • @CppNuts
      @CppNuts  7 лет назад +1

      Correct!! Thanks..

    • @fixpontt
      @fixpontt 7 лет назад +3

      somebody read a lot of Scott Meyers' books :DD

    • @CppNuts
      @CppNuts  7 лет назад

      +Fixpont i like him so much..
      But never got the chance to read the books.

  • @ravi2606711
    @ravi2606711 6 лет назад +1

    This code is giving segmentation fault. why?
    #include
    using namespace std;
    class Singleton
    {
    static Singleton* instance;
    int width;
    int height;
    int brightness;
    Singleton():width(23),height(34),brightness(83){}
    public:
    int getWidth()
    {
    return width;
    }
    int getHeight()
    {
    return height;
    }
    int getBrightness()
    {
    return brightness;
    }
    void setHeight(int h)
    {
    height=h;
    }
    void setWidth(int w)
    {
    width=w;
    }
    void setBrightness(int b)
    {
    brightness=b;
    }

    static Singleton* getInstance()
    {
    if(instance==NULL)
    {
    instance=new Singleton;
    return instance;
    }
    }

    void display()
    {
    cout

    • @CppNuts
      @CppNuts  6 лет назад

      Hi Ravi, i tested your code but it is not seg fault for me here.

    • @ravi2606711
      @ravi2606711 6 лет назад

      But while running this code online I am getting segmentation fault

  • @rajeshrathod9329
    @rajeshrathod9329 7 лет назад +1

    Here given design is not thread safe what is the reason you haven't considered that point ?

    • @CppNuts
      @CppNuts  7 лет назад +1

      Hi Rajesh, Actually it becomes little tough for some people to understand locking mechanism, so i thought i will include that in another part of this video, but still haven't got enough time to look back to this topic. Will try to covert that part ASAP.
      Thanks for reminding the point here. :)

  • @totolanouille
    @totolanouille 4 года назад +1

    Missing const for getters

  • @sauravgupta6166
    @sauravgupta6166 3 года назад

    Please create a Discord Server for us!! 🙏🙏🙏

  • @ankitthakar2671
    @ankitthakar2671 5 лет назад +1

    I am not able to access the cppnuts.com website

    • @CppNuts
      @CppNuts  5 лет назад

      I have shut it down.

    • @ankitthakar2671
      @ankitthakar2671 5 лет назад +1

      @@CppNuts Will it be open again?

    • @CppNuts
      @CppNuts  5 лет назад

      I am thinking of making another website, may take time.

  • @chunbochen9976
    @chunbochen9976 6 лет назад +3

    I am wondering who will delete the _instance, otherwise it will have memory leak

    • @CppNuts
      @CppNuts  6 лет назад

      That is another topic how to delete singleton pointer, please google it you will get so much of information

    • @williamreji435
      @williamreji435 3 года назад

      You can literally leave it to os..since the pattern is used mostly for heavy objects...

  • @DGDG0000000
    @DGDG0000000 6 лет назад +1

    The problem here is that there should have memory leakage. The object can be never deleted, never deallocated.
    You can use smart pointers (shared_ptr and weak_ptr) for resolve this big problem.

    • @CppNuts
      @CppNuts  6 лет назад +1

      Hi, Your thinking is correct, and i am giving one more solution to this problem if someone don't know the use of smart pointers.
      Solution: Include this function inside your class.
      static void resetInstance() {
      delete _instance;
      _instance = nullptr;
      }
      This is equal to getInstance function, but this will delete the pointer we created and we won't have memory leaks.
      The only point is you will have to remember this and call only when you are leaving the program, is that at the end of main function, otherwise there will be many construction and destruction and you will lose your state in b/w.
      Nice point to discuss i should include this in some video, thanks for pointing out this.

    • @DGDG0000000
      @DGDG0000000 6 лет назад +1

      yes, that's correct.
      There is many singleton design pattern, an other one is to use static class also.
      By the time, smart pointers resolve many problems and it is easy to implement. With singleton, use of smart pointer absolutly need to use weak_ptr also... if you want the code, i can give you one.
      But actually, most of devs are thinikng that singleton most of the time is not great t use due to problem with threads. Lot of them said that it is a bad design pattern. Actually, i'm using it, but i'm looking for an other way to design my code without singleton.

    • @CppNuts
      @CppNuts  6 лет назад

      Nothing is bad if you know what you are doing and what is your scope, that would be foolish if some tell hypothetically about the problem you have in YOUR hand, THEY DON'T KNOW YOUR PROBLEM.
      Yes it makes problem when it comes to threading but there are solution to that as well, i often see getSingleInstace() in my project and we didn't need threading involved so we have singleton without thread safety.
      So go for it, after looking at all the possibilities and choose whichever suits your need best.

    • @DGDG0000000
      @DGDG0000000 6 лет назад +1

      Yes, i understand that.
      I have to ask you if you know some other technic(s) who should garanty unicity call of object and be safe when multi process ?
      For example, in my program, (it is a Qt GUI framework used), a window can use the singleton (two in fact: one for XML data wrapper, one for a specific Potsgresql database access for general datas embeded), and call an other dialog box who can also use it in the same time (in parrallel) so... it is not a thread call directly, but it has to be use the same singleton at the same time... that could become a problem for me sometimes.
      I'm searching for ideas about that.

    • @CppNuts
      @CppNuts  6 лет назад +1

      If you say "at the same time" then it is not thread safe. please look at these articles, might help you in that case. And sorry for dumping these many links, i did this because you know your problem better than me so you decide which is better solution to that problem :).
      Links:
      stackoverflow.com/questions/2576022/efficient-thread-safe-singleton-in-c
      www.codeproject.com/Articles/96942/Singleton-Design-Pattern-and-Thread-Safety
      www.aristeia.com/Papers/DDJ_Jul_Aug_2004_revised.pdf
      ruclips.net/video/c1gO9aB9nbs/видео.html&t=18m40s

  • @adithyaks8584
    @adithyaks8584 4 года назад +1

    This will not be threadsafe. Use a mutex to guard around the NULL check and object creation part

    • @CppNuts
      @CppNuts  4 года назад

      Thread safe is another topic.

  • @181Ravikiran
    @181Ravikiran 5 лет назад

    #include
    using namespace std;
    class System{
    private:
    static System *obj;
    public:
    static System &getInstance(){
    static System theInstance;
    return theInstance;
    }
    void prn(){
    cout

  • @vladimirkraus1438
    @vladimirkraus1438 5 лет назад

    This is a very wrong implementation. The singleton object class must not create the instance itself. Just make the constructor public (with NULL assertion), and nullify the instance pointer in destructor... Then create the singleton instance on the stack in main() just before it is first used. Then there will be no memory leak and you will have your singleton easily testable (by inheriting a mocked version) and creating a scope limited fresh new instance of the singleton in every unit test. Simple and elegant. All the criticized problems of singleton will be gone (except for multithreaded R/W access - but you better should not use singleton then).

    • @CppNuts
      @CppNuts  5 лет назад

      Hi Vladimir, i got the point but how would you have single instance through out the application.
      As you will create object on Stack, it will call destructor as it goes out of scope and next time you need it you will have to recreate it again (you have lost the previous state of the object which is important).
      Singletons are meant to store information through out the life time of the application.

  • @suboomdeb3572
    @suboomdeb3572 4 года назад

    so many adds, kiled my intrests

    • @CppNuts
      @CppNuts  3 года назад

      Sorry for that..