In Nicola Gigante's lecture in 2015, he mentions (at the beginning) that there are no pure virtual functions in the Standard Library (or he's not aware of any). I believe that Alex Stepanov was against this language feature but since the initial STL design, have any pure virtuals creeped into the Standard library?
FWIW (and correct me if I'm wrong) the deleters in unique pointers ultimately use virtual dispatching in most implementations but these are not pure virtuals.
A pure virtual function or pure virtual method is a virtual function that is required to be implemented by a derived class if the derived class is not abstract. Classes containing pure virtual methods are termed "abstract" and they cannot be instantiated directly.
A class is abstract if it has at least one pure virtual function. Unfortunately, there are cases when one cannot add a pure virtual method to a class to turn it in an abstract one and still he doesn't want users to be able to instantiate that class.
An abstract class is a class in C++ which have at least one pure virtual function.
In C, virtual function calls look unlike any other kind of function call. For example, a call to the virtual area function applied to a shape looks like: shape *s;~~~s->vptr->area(s);
[syserr.errcat.overview] has std::error_category
class error_category { virtual const char* name() const noexcept = 0; virtual string message(int ev) const = 0; };
There are no others in C++14.
C++17 adds std::pmr::memory_resource
in [mem.res.class] to the one in C++14, with the following private
pure virtual functions:
class memory_resource { virtual void* do_allocate(size_t bytes, size_t alignment) = 0; virtual void do_deallocate(void* p, size_t bytes, size_t alignment) = 0; virtual bool do_is_equal(const memory_resource& other) const noexcept = 0; };
And yes, private virtual functions can be overridden.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With