Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
How can I make a complicated linked list
I design a class "Item", and two classes "Table", "Chair" inherited from class "Item".
I want to make a linked list that each node can be "Table" or "Chair", so I decide to use the linked list of "Item", hope that each object can be declared like this:
Item one_node = new Table();
But then, I can not use the variable "one_node" as an object of "Table".
That is my problem. Anyone can help me to create a linked list where each node can be an object of some classes inherited from one class? And can the depth of the inheritance be more than one?
Sorry if my english is bad.
0 · ·