• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Sql
  • php
  • C program
  • Seo

Codelack.com

  • Home
  • C++
  • networking
  • Sql server
    • what is rdbms | one to one | one to many | many to many relation-codlack
    • sql server create table
    • code rules in sql server
  • ASP.NET
    • control state in asp.net
    • cookie in asp.net
    • datalist control in asp .net
    • Using ASP.NET To Send Email
    • application state in asp.net
    • file upload control in asp.net
  • contact us
  • Data structure
    • what is Data structure
    • doubly linked list program in c
    • Array in data structure
    • circular queue in data structure
    • Linear data structure
    • Delete node at any position in singly linked list
    • dequeue in data structure
    • implementation of stack using a Linked list in data structure
    • implementation of stack using array in data structure
    • linked list algorithm
    • linked list in data structure
  • C
    • continue and break in c
    • history of c programming language
    • array program in c
    • c programming practice questions
    • enumeration in c
    • C programs with solutions
    • Characteristic of c
    • print 1 to 100 without using loop in c program
    • two single dimension 2D array in c
  • php
    • php
    • Variables in PHP
    • Scalar data types in php
    • Output function in php
    • how to use php string functions | example of string function
    • point to point configuration
    • error in php
    • Array in  php

destructor in c++ | How to call destructor C++

The destructor  is a special member function whose name is same as the class name, but it is preceded by a tiled symbol(~).

For Example :-. 

the destructor for the class Example will bear the name  ~Example().

Definition of Destructor in C++ :-

A destructor is a member function and can be defined like any other member function. However, it doesn’t take any argument neither does it return any value.

Destructor destroys class objects created by constructor.

Note :-

Generally, A destructor should be defined under the public section of a class and it object can be destroyed in any function.

“dtor” is typical abbreviation for destructors.


following code piece outlines it

class Demo  {  int i, int j;
~Demo(){cout << "Destructing \n";}  // private destructor .
public :
 Demo(){i=0;j=0;}  // constructor
 void memb1(void);
 void memb2(void);
	
};
void Demo :: memb1(void)
{
	Demo s1 ; /* valid. object can be used here.it is a member functon 
	and  thus has an access to its private destructor */ 
}
void Demo :: memb2(void)
{
	Demo  s2 ; 
}
void abc (void)
{
	Demo s3; /*  valid.abc is a friend function and 
	thus has an access to sample's private members.*/
}

int main()
{
	Demo s4; /* invalid main() is a nonmember function and thus cannot access  
private members (destructor also as it is private). */
}

Some Characteristics of Destructors

The destructors have some special characteristics associated. These are : 

  1. A destructor is automatically executed when object goes out of the scope.
  2. A destructor does not have return type and not even void.
  3. Destructor can be virtual, but constructors can not .
  4. Only one destructor can be defined in  a class.
  5. The destructor does not have any  arguments.
  6. An object of a class with a destructor cannot be a member of a union.
  7. A destructor may not be static.
  8. They cannot be inherited.
  9. Not possible to take the address of a destructor.
  10. Member function may be called from within a destructor.
  11. Destructors can’t be overloaded.

Primary Sidebar

sql

  • introduction of sql
  • database management system
  • hierarchical database management system
  • what is rdbms | one to one | one to many | many to many relation-codlack
  • codd rules in sql server
  • Character Data Type
  • constraint unique
  • sql server create table

Ads

data structure

  • Data structure
  • Linear data structure
  • Array in data structure
  • What is a algorithm
  • stacks in data structure
  • queue data structure
  • dequeue in data structure
  • Priority queue
  • circular queue in data structure
  • linked list algorithm
  • Delete node in singly linked list
  • tree in data structure
  • implementation of stack using array in data structure
  • implementation of stack using a Linked list in data structure
  • Doubly Linked List Implementation

C programming

  • history of c programming language
  • C programs with solutions
  • Characteristic
  • constraint unique
  • continue and break
  • doubly linked list program in c
  • dynamic memory allocation
  • enumeration
  • print 1 to 100 without using loop
  • Variable declaration

c++

  • Introduction to C++ || similarities of  C++ structure and  class
  • default argument in c++
  • access specifiers in c++
  • Function In C++
  • friend function in c++
  • constructor in c++
  • destructor in c++ | How to call destructor C++
  • exception handling in c++

Categories

array multiplication (1) asp.net (10) B.ed (1) C# (1) c# (1) C++ (2) C program (3) FormView control (1) php (2) Seo (5) Sql (1) Uncategorized (10)
disclaimer

Copyright © 2022 · codelack.com