In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of "what is the destructor of C++". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The destructor (destructor), in contrast to the constructor, automatically executes the destructor when the object is out of its scope (for example, the function in which the object is located has been called). Destructors are often used to clean up the aftermath (for example, opening up a memory space with new when creating objects, which should be freed with delete in the destructor before exiting).
Some of the previous examples do not illustrate destructors because the classes used do not require special cleanup at the end. The following program gives a new Date class that includes a string pointer to represent the month.
# include\ "iostream.h\" # include\ "string.h\" class Date {int mo,da,yr; char * month; public: Date (int masking 0, int dumb0, int yearly 0); ~ Date (); void display () const;} Date::Date (int January int djinint y) {static char * mos [] = {\ "January\",\ "February\",\ "March\",\ "April\",\ "May\",\ "June\",\ "July\",\ "August\",\ "September\",\ "October\",\ "November\",\ "December\"}; mo=m; da=d; yr=y If (month; 0) {month=new char [strlen (MOSs [m-1]) + 1]; strcpy (month, MOSs [m-1]);} else month= 0;} Date::~Date () {delete [] month;} void Date::display () const {if (MOs [m-1]) cout
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.