mirror of
https://github.com/RYDE-WORK/pybind11.git
synced 2026-02-02 13:15:52 +08:00
Adapt code example in advanced/classes.rst to new handling of forgetting to call the superclass __init__ (#2429)
This commit is contained in:
parent
4493751a5f
commit
b3d8fec066
@ -159,7 +159,7 @@ Here is an example:
|
|||||||
|
|
||||||
class Dachshund(Dog):
|
class Dachshund(Dog):
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
Dog.__init__(self) # Without this, undefined behavior may occur if the C++ portions are referenced.
|
Dog.__init__(self) # Without this, a TypeError is raised.
|
||||||
self.name = name
|
self.name = name
|
||||||
def bark(self):
|
def bark(self):
|
||||||
return "yap!"
|
return "yap!"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user