![]() ![]() Destructors do not have a return type.We have to fully deallocate memory what we have allocated. Because we do not need to deallocate memory in different ways (partially/fully). So, we cannot overload it as a constructor. When it comes to declaration a destructor, we need to follow some rules. for example ~Test() is the destructor for class Test. ![]() We can declare a destructor by adding a tide (~) as prefix to its class name. In this article, we are planning to discuss how to work with destructors properly including declaration rules, why we need it? When we need it? How to declare a destructor? Which is to deallocate assigned memory and do other cleanup related to a class object when the object is destroyed. We simply state that destructor is the inverse of the constructor. If you have programmed in C++ with OOP concepts, you all might know that C++ has this strange feature called “Destructor”. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |