Is this exactly C ++? If you cannot use constructors, destructors, operators, then it is easier to write in C probably. There just will be only the structure.
About biconnected lists - instead of int use pointers to your structures, you need to figure out how to allocate memory for structures, how to free this memory, and that's it ( new/delete plus or malloc/free ).
Then just spawn the structure under your entities, and write the functions that create them, fill, delete, etc.
Judging by the assignment, you are required to make a list of groups, that is, one structure describes a group ( простая your words), another (s) structures are required to create a doubly linked list of these structures.
Example:
#include <stdio.h> #include <string.h> #include <stdlib.h> typedef struct{ int a; char* text; }data; data* create_data(int a, const char* text){ data* ret = malloc(sizeof(data)); ret->a = a; size_t text_len = strlen(text); ret->text = malloc(sizeof(char) * (text_len + 1)); ret->text = strcpy(ret->text, text); return ret; } void free_data(data* d){ if (d->text != NULL){ free(d->text); d->text = NULL; } } typedef struct node{ data* d; struct node* next; struct node* prev; }node; node* create_node(data* d){ node* ret = malloc(sizeof(node)); ret->next = NULL; ret->prev = NULL; ret->d = d; return ret; } void free_node(node* n){ if (n->d != NULL){ free_data(n->d); free(n->d); n->d = NULL; } } typedef struct{ node* head; node* tail; }linked_list; linked_list* create_list(){ linked_list* ret = malloc(sizeof(linked_list)); ret->head = NULL; ret->tail = NULL; return ret; } void free_list(linked_list* l){ node* cur = l->head; while (cur != NULL){ free_node(cur); cur = cur->next; if (cur != NULL){ if (cur->prev != NULL) free(cur->prev); } } } linked_list* add_to_tail(linked_list* l, data* d){ node* new_node = create_node(d); new_node->next = NULL; new_node->prev = l->tail; if (l->tail == NULL){ l->tail = new_node; l->head = new_node; }else{ l->tail->next = new_node; l->tail = new_node; } return l; } void print_list(linked_list* l){ node* cur = l->head; while (cur != NULL){ printf("node a:%d text:%s\n", cur->d->a, cur->d->text); cur = cur->next; } return; } int main() { linked_list* list = create_list(); for (int i = 0; i < 10; i++){ list = add_to_tail(list, create_data(i, "hello")); } print_list(list); free_list(list); free(list); return 0; }
Conclusion:
node a:0 text:hello node a:1 text:hello node a:2 text:hello node a:3 text:hello node a:4 text:hello node a:5 text:hello node a:6 text:hello node a:7 text:hello node a:8 text:hello node a:9 text:hello