Classes#######
This section presents advanced binding code for classes and it is assumed
that you are already familiar with the basics from :doc:`/classes`.
.._overriding_virtuals:Overriding virtual functions in Python======================================
Suppose that a C++ class or interface has a virtual function that we'd like to
to override from within Python (we'll focus on the class ``Animal``; ``Dog`` is
given as a specific example of how one would do this with traditional C++
code).
..code-block::cppclassAnimal{public:virtual~Animal(){}virtualstd::stringgo(intn_times)=0;};classDog:publicAnimal{public:std::stringgo(intn_times)override{std::stringresult;for(inti=0;i<n_times;++i)result+="woof! ";returnresult;}};
Let's also suppose that we are given a plain function which calls the
function ``go()`` on an arbitrary ``Animal`` instance.