This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: abstractmethod vs C++ pure virtual
Type: Stage:
Components: Documentation Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: georg.brandl, jaredgrubb
Priority: normal Keywords:

Created on 2009-02-23 05:11 by jaredgrubb, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg82618 - (view) Author: Jared Grubb (jaredgrubb) Date: 2009-02-23 05:11
On page library/abc.html documenting abc.abstractmethod, the following
text about C++ is placed in a note:

"Note: Unlike C++’s pure virtual functions, or Java abstract methods,
these abstract methods may have an implementation. This implementation
can be called via the super() mechanism from the class that overrides
it. This could be useful as an end-point for a super-call in a framework
that uses cooperative multiple-inheritance."

This is not an accurate description of C++'s pure virtual functions.
Pure virtual functions CAN have an implementation, which can be called
from derived classes; this makes them behave just like Python's
abstractmethod.

Example:
struct Abstract {
   virtual void foo() = 0;
};
void Abstract::foo() {
   std::cout << "pure virtual function called";
}
struct Derived : public Abstract {
   virtual void foo() { 
       Abstract::foo(); // call the abstract impl
   }
};
msg82624 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-02-23 11:24
Thanks, fixed in r69901.
History
Date User Action Args
2022-04-11 14:56:46adminsetgithub: 49599
2009-02-23 11:24:52georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg82624
2009-02-23 05:11:37jaredgrubbcreate