同时接受任何类型的对象的链接清单
是否可以实现一个同时接受任何类型对象的链表?
例如: list.add(int) 、 list.add(float) 、 list.add(object1) 、 list.add(object2)
正如你所看到的,我在同一个列表中添加了不同的类型。
Is it possible to implement a linkedlist that accept any type of objects at same time ?
for example : list.add(int) , list.add(float) , list.add(object1) , list.add(object2)
as you can see i added different types in the same list.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以利用
std ::任何
来满足您的需求。有一个示例,说明如何将元素添加到
std :: list< std :: Any>
以及如何从std :: list< std&std :: Any>中读取元素。
。You can utilize
std::any
to suit your needs.There is an example of how to add an element to a
std::list<std::any>
and how to read an element from astd::list<std::any>
.