❔ help with self referential class typing
I was trying to make a node class I can inherit from and ran into a ton of trouble,
in my original solution the "next" value was still a node rather then the child class, I looked around and people were saying to use a self referential generic class signature so I used this:
and started writing, I even got some inheritance to work,
however I ran into a few problems in some of the functions:
in this function for example, how can I make a new "Self" object? as I do not know what constructors it has. and if I try to build a node I cant set it as next as I expect a Self
object, am I missing a trick to get this to work?
in my original solution the "next" value was still a node rather then the child class, I looked around and people were saying to use a self referential generic class signature so I used this:
and started writing, I even got some inheritance to work,
however I ran into a few problems in some of the functions:
in this function for example, how can I make a new "Self" object? as I do not know what constructors it has. and if I try to build a node I cant set it as next as I expect a Self
object, am I missing a trick to get this to work?