Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

abstractmethod vs C++ pure virtual #49599

Closed
jaredgrubb mannequin opened this issue Feb 23, 2009 · 2 comments
Closed

abstractmethod vs C++ pure virtual #49599

jaredgrubb mannequin opened this issue Feb 23, 2009 · 2 comments
Assignees
Labels
docs Documentation in the Doc dir

Comments

@jaredgrubb
Copy link
Mannequin

jaredgrubb mannequin commented Feb 23, 2009

BPO 5349
Nosy @birkenfeld

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/birkenfeld'
closed_at = <Date 2009-02-23.11:24:52.608>
created_at = <Date 2009-02-23.05:11:37.643>
labels = ['docs']
title = 'abstractmethod vs C++ pure virtual'
updated_at = <Date 2009-02-23.11:24:52.607>
user = 'https://bugs.python.org/jaredgrubb'

bugs.python.org fields:

activity = <Date 2009-02-23.11:24:52.607>
actor = 'georg.brandl'
assignee = 'georg.brandl'
closed = True
closed_date = <Date 2009-02-23.11:24:52.608>
closer = 'georg.brandl'
components = ['Documentation']
creation = <Date 2009-02-23.05:11:37.643>
creator = 'jaredgrubb'
dependencies = []
files = []
hgrepos = []
issue_num = 5349
keywords = []
message_count = 2.0
messages = ['82618', '82624']
nosy_count = 2.0
nosy_names = ['georg.brandl', 'jaredgrubb']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue5349'
versions = ['Python 2.6']

@jaredgrubb
Copy link
Mannequin Author

jaredgrubb mannequin commented Feb 23, 2009

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

@jaredgrubb jaredgrubb mannequin assigned birkenfeld Feb 23, 2009
@jaredgrubb jaredgrubb mannequin added the docs Documentation in the Doc dir label Feb 23, 2009
@birkenfeld
Copy link
Member

Thanks, fixed in r69901.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

1 participant