Message82618
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
}
}; |
|
Date |
User |
Action |
Args |
2009-02-23 05:11:39 | jaredgrubb | set | recipients:
+ jaredgrubb, georg.brandl |
2009-02-23 05:11:38 | jaredgrubb | set | messageid: <1235365898.93.0.530994283024.issue5349@psf.upfronthosting.co.za> |
2009-02-23 05:11:37 | jaredgrubb | link | issue5349 messages |
2009-02-23 05:11:36 | jaredgrubb | create | |
|