Is it possible to have a linked list of different data types?

后端 未结 11 2098
独厮守ぢ
独厮守ぢ 2020-12-13 22:22

This is just another interview question.

Can we have a linked list of different data types, i.e. each element in a linked list can have different structure or union

11条回答
  •  抹茶落季
    2020-12-13 23:19

    You can have each node in a linked list have a void* that points to your data. It's up to you how you determine what type of data that pointer is pointing to.

提交回复
热议问题