Skip to content

第二次作业 #80

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

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

Conversation

DXBlackSmith
Copy link

学习了别人的代码,学到了迭代器的写法

新增了 reference.cpp 和 ans.cpp ,前者是我学习迭代器写的笔记,后者把迭代器应用在作业当中

  1. 会造成循环引用的问题,导致开辟的两块内存得不到释放
  2. 可以用初始化列表减少一次构造,同时可以声明为 explicit 使得其必须被显式构造
  3. 应该输出14次,但是因为有内存没有得到释放的问题
  4. 深拷贝的实现在 ans.cpp ,用了学习到的迭代器
  5. 我的理解是在主函数中只用到了拷贝构造,所以这里没报错
  6. 这里能用常量引用的方式,减少无谓的拷贝次数

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