Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝unique_ptr & normal ptr #55

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Meow-2
Copy link

@Meow-2 Meow-2 commented Mar 18, 2022

作业要求

  • 避免函数参数不必要的拷贝 5 分
    • void print(const &)
  • 修复智能指针造成的问题 10 分
    • shared_ptr互相指,导致a={}b={}后链表无法释放
  • 改用 unique_ptr<Node> 10 分
    • 改用unique_ptr和普通指针
  • 实现拷贝构造函数为深拷贝 15 分
    • 构造一条一样的链表
  • 说明为什么可以删除拷贝赋值函数 5 分
    • 在赋值时会调用拷贝构造函数,构造出一个临时对象,然后就可以移动赋值了
  • 改进 Node 的构造函数 5 分
    • 增加了一个Node构造函数,允许将next和prev作为构造函数的参数

模板

  • 将Node和List改为模板
  • 为print函数添加 int 和 char 的特化

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant