In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "why C++ should avoid displaying and calling new and delete". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought slowly and deeply. Let's study and learn "why C++ avoids displaying and calling new and delete".
R.11: avoid displaying calls to new and delete
Reason (reason)
The pointer returned by new should be managed by the handle of the resource (the one responsible for calling delete). If the pointer returned by new is assigned to the original pointer, the object may have a memory leak.
Note (Note)
In large-scale programs, exposed deletions (calling delete in the application code rather than handing it over to resource management) can trigger bug: if there are N times of delete, how can you be sure that you don't need it once? Bug may be potential: it may occur after some maintenance. If there is a direct new operation, you may need to invoke the direct delete operation somewhere, so a bug may be thrown.
Enforcement (implementation recommendations)
(simple) warn of any explicit calls to new and delete. Make_unique is recommended.
Thank you for your reading, the above is "Why C++ should avoid displaying calls to new and delete" content, after the study of this article, I believe you have a deeper understanding of why C++ should avoid displaying calls to new and delete, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.