New submission from Jared Grubb <pyt...@jaredgrubb.com>:

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
   }
};

----------
assignee: georg.brandl
components: Documentation
messages: 82618
nosy: georg.brandl, jaredgrubb
severity: normal
status: open
title: abstractmethod vs C++ pure virtual
versions: Python 2.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue5349>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to