如何在两个结构中使用链表 [英] How to use Linked List with two struct

查看:98
本文介绍了如何在两个结构中使用链表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的英语不好,所以可能会有一些拼写错误

我有一个小项目,管理一个图书馆.我使用2种结构:
管理库中帐户的第一个结构
管理图书馆书籍的第二个结构.因此,如何在不创建两个链表的情况下使用单链表来管理两个结构

我还没学过OOP

谢谢!!!

解决方案

我可以用template<class t>来做到吗?
T代表struct


创建第三个结构,并包含第一个和第二个结构的对象作为其成员.

struct One
{
   ...
};

struct Two
{
   ...
};

struct ListContent
{
   One one;
   Two two;
};

是的,请使用std::list而不是创建链接列表.


感谢大家的帮助!!!!!!


I''m not good at English so may have some spelling errors

I have a small project, manage a library. I use 2 structs:
first struct to manages accounts in library
second struct to manages library books. So how to use Single Linked List to manage both of struct without creating two Linked Lists

I haven''t learned OOP

Thanks !!!

解决方案

Can I use template<class t> to do it?
T represents struct


Create a third structure and include objects of the first and second structure as its members.

struct One
{
   ...
};

struct Two
{
   ...
};

struct ListContent
{
   One one;
   Two two;
};

And yes, use std::list instead of creating a linked list.


thank you all for yours help !!!!!!


这篇关于如何在两个结构中使用链表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆