Pergunta

I think of a situation when one needs to code a linked list implementation as a generic ADT. Is he supposed to provide within the library printing functions?

Because is we assume that the client will use the linked list with his own created struct than how can the printing method know how to print the data of that struct?

Foi útil?

Solução

A list has many inherent abilities. Printing is not one of them. For the sake of purity, I would not implement printing if I were asked to implement a linked list. Seperation of concerns is the guideline here.

On the other hand, the only correct answer is "ask your boss". If you are supposed to code this for someone, ask him. He will know better what he expects than a few random people on the internet.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top