修改 cpp_lifetime.md 中的措辞与问题 - #72
Open
Mq-b wants to merge 1 commit into
Open
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
delete p;的注释仅为“释放动态分配的内存”不合适,根据上下文,此处还应强调调用析构函数。律师的话并不够准确。且我认为之前的描述也存在一些问题。
我认为关键在于强调
p是什么,*p是什么,以及说明常用词汇“指向”到底代指着什么。另外有必要强调
*p返回的是指针所指向对象的引用,我认为大多数开发者事实上并不清楚这一点。内建的取址符(*)的操作数必须是指向对象或指向函数的指针,其结果是一个 lvalue,引用的是操作数所指向的对象或函数。
T& operator*(T*);