I'm writing a program that supports many data structures (stacks,heaps etc.) made from scratch. However the program does not limit you to just one stack, one heap etc. but you can have as many as you like. I'm looking for a way to store all the different stacks into one singly-linked list and then all the heaps into another singly-linked list etc. So basically I'd like to make a class (for example "class linkedlist") that supports a list that is not dependant on each data structure. It's confusing but maybe you'll get what I mean by code:
Expand|Select|Wrap|Line Numbers
- class linkedlist
- {
- private:
- struct structureIDs
- {
- int ID;
- <<class name goes here>> newStructure;
- struct structureIDs *next;
- }*head;
- public:
- //...
- };
Expand|Select|Wrap|Line Numbers
- class linkedlist
- {
- private:
- struct structureIDs
- {
- int ID;
- stack stackno1; //Assuming that the class that creates a stack is named "stack"
- struct structureIDs *next;
- }*head;
- public:
- //...
- };
Expand|Select|Wrap|Line Numbers
- class linkedlist
- {
- private:
- struct structureIDs
- {
- int ID;
- heap heapno1; //Assuming that the class that creates a heap is named "heap"
- struct structureIDs *next;
- }*head;
- public:
- //...
- };
Really hope you people answer, thanks in advance!