Conversation
Contributor
|
不!小彭老师背地里cue白律师被发现了 😭 |
archibate
reviewed
Dec 20, 2024
| @@ -75,7 +75,7 @@ void func() { | |||
| ```cpp | |||
| void func() { | |||
| Class *p = new Class; // *p 是动态存储周期 | |||
Contributor
Author
There was a problem hiding this comment.
此处你没说申请内存,我就没管,认为你只是想强调 *p 是动态存储期。看你心情。
Contributor
Author
|
此pr为何还没合并😨( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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*);