How do I make this C++ object non-copyable?

前端 未结 10 991
太阳男子
太阳男子 2020-11-28 04:36

See title.

I have:

class Foo {
   private:
     Foo();
   public:
     static Foo* create();
}

What need I do from here to make Fo

10条回答
  •  孤街浪徒
    2020-11-28 05:06

    Make the copy constructor private.

    Foo(const Foo& src);
    

    You don't need to implement it, just declare it in the header file.

提交回复
热议问题