I have a member of a class that is a type of my class, like a linked list:
class MyLinkedList {
...
public MyLinkedList next;
...
}
When I extend this class
class MyExtendedLinkedList extends MyLinkedList{
...
public doStuff(){
...
}
}
I can not do something like
MyExtendedLinkedList myExLL = ...
myExLL.next.doStuff();
Since it nextdoes not return an instance MyExtendedLinkedList. Obviously this can be done with type casting, but is there a compile-time type safe declaration method nextso that I can get a derived type for all my derived classes?
source
share