When using the following code to disable copy and assignment:
Foo(const Foo&) = delete;
Foo& operator=(const Foo&) = delete;
Will this also automatically disable copy and assigment of child classes of Foo?
class Bar : public Foo {
}
Or, in other words, can Bar
be copied?
Yes, this also inhibits implicit copying of child classes. In fact that's how inheriting from boost::noncopyable
(http://www.boost.org/doc/libs/master/libs/core/doc/html/core/noncopyable.html) works. However someone could always write their own copy constructor/copy assignment for the child class that doesn't actually copy the Foo
component, or copies it in a different way.