| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
不!小彭老师背地里cue白律师被发现了 😭 |
Sorry, something went wrong.
| @@ -75,7 +75,7 @@ void func() { | |||
| ```cpp | |||
| void func() { | |||
| Class *p = new Class; // *p 是动态存储周期 | |||
There was a problem hiding this comment.
那这里是否也要强调分配了内存并调用构造函数?
Sorry, something went wrong.
There was a problem hiding this comment.
此处你没说申请内存,我就没管,认为你只是想强调 *p 是动态存储期。看你心情。
Sorry, something went wrong.
There was a problem hiding this comment.
加上吧,多说不算错。
Sorry, something went wrong.
|
此pr为何还没合并😨( |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
delete p; 的注释仅为“释放动态分配的内存”不合适,根据上下文,此处还应强调调用析构函数。
律师的话并不够准确。且我认为之前的描述也存在一些问题。
我认为关键在于强调 p 是什么,*p 是什么,以及说明常用词汇“指向”到底代指着什么。
另外有必要强调 *p 返回的是指针所指向对象的引用,我认为大多数开发者事实上并不清楚这一点。
内建的取址符(*)的操作数必须是指向对象或指向函数的指针,其结果是一个 lvalue,引用的是操作数所指向的对象或函数。
T& operator*(T*);