class Scheduler {
public:
static Scheduler& instance() {return (*instance_); }
protected:
static Scheduler* instance_;
};
就是这句static Scheduler& instance() {return (*instance_); },我知道Scheduler& 表示函数返回值是Scheduler的引用,不明白的是return (*instance_);表明返回的是指
针的指针吗?有点晕呀
instance()是个函数,这个函数返回一个Scheduler类型的引用;且,这个函数被static修饰,它只在类Scheduler之外形成一份拷贝,是类Scheduler的所有对象共用的函数!
所谓“返回一个Scheduler类型的引用”就是返回一个Scheduler类的对象的别名!

相关文章:

  • 2022-01-15
  • 2022-12-23
  • 2022-12-23
  • 2022-03-02
  • 2021-12-12
  • 2021-09-27
  • 2021-11-23
猜你喜欢
  • 2022-12-23
  • 2021-09-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
相关资源
相似解决方案