-Wunused-variable warning

后端 未结 1 1882
一生所求
一生所求 2021-01-26 04:24

I am implementing the singleton design pattern in a school assignment, and this is my class header file:

class Scheduler {
public:
    static Scheduler * instanc         


        
相关标签:
1条回答
  • 2021-01-26 05:01

    Your static singleton instance pointer should be a class member. Currently it is just a free pointer.

    class Scheduler {
    // as before
    private:
        Scheduler();
        static Scheduler* _singleton; // declare it in the class
    };
    

    and in the implementation file:

    Scheduler * Scheduler::_singleton = 0;
    
    0 讨论(0)
提交回复
热议问题