TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Monday 22 June 2020

Destructor In C++ | Definition Of Destructor In C++ | Use Of Destructor In C++ | Feature Of Destructor In C++ | Destructor In C++ Syntax| Destructor In C++ With Program And Output|Destructor In C++ In Hindi

Destructor In C++


Destructor is a member function which destructs or deletes an object.
A destructor function is called automatically when the object goes out of scope:
the function ends the program ends a block containing local variables ends a delete operator is called Destructors have same name as the class preceded by a tilde (~) Destructors don’t take any argument and don’t return anything.

image of Destructor In C++
Fig: destructor in c++

Synatx:

class classname

{

----

----

public:

~classname();

-----

-----

-----

};

Program:

#include<iostream.h>

#include<conio.h>

class BCA

{

int a,b;

public:

BCA();

{

Cout<<”constructor create”;

}

~BCA()

{

cout<<”Destructor create”;

}

void input()

{

cout<<”input value”;

cin>>a>.b;

void output()

{

cout<<”a=”<<a;

cout<<”b=”<<b;

}

};

void main()

{

BCA a1;

a1.input();

a1.output();

getch();

}


Output:

Constructor create 2 2

22

 

Feature Of Destructor In C++ 

    1. It is invoked when object goes out of the scope

   2.  Like constructor, it can also have parameters   

   3.  It can be virtual   

  4.  It can be declared in private section

 


No comments:

Post a Comment