Open ryanmrichard opened 9 months ago
I think we would need to introduce a super()
construct for this to work. Currently, to support polymorphism the subclass completely replaces the vtable entry (terminology for other languages, don't remember what we call it) for the to_str
method so that you can pass a Foo
into something expecting a Bar
and still get the overridden functionality.
I think introducing super()
to solve this is a great idea!
Describe the bug I have a simple two class hierarchy,
Foo
which derives fromBar
. InBar
I define a methodto_str
meant to printBar
. InFoo
I try to overrideto_str
so that it first callsBar::to_str
then printsFoo
's additional state; instead I get infinite recursion.To Reproduce MWE:
Expected behavior I would expect the code to print
"Value = \nOther Value = world"
Additional context N/A