1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
xz_007 [3.2K]
3 years ago
5

. What is a destructor and what is its purpose?

Computers and Technology
1 answer:
NISA [10]3 years ago
5 0

Answer:

Destructor is a function or method which is used to deallocated the memory which is allocated by the constructor in the program.The destructor is used to delete the object or destruct the object.

Explanation:

The Purpose of Destructor is to delete the object from the memory which is created by Constructor.

The Destructor have same name as the class name in c++.

In c++ we use destructor like that

#include <iostream>

using namespace std;

class Hello

{

   public:

       Hello () //constructor defined

      {

     cout << "Hey constructor is called here:" << endl;

      }

      ~Hello() //destructor defined

      {

            cout << "Now destructor is called here:" << endl;

      }

};

int main()

{

    Hello h; //constructor is called

    cout << "function main is closing...." << endl;

   

    return 0;

}  

You might be interested in
An email message containing a warning related to a non-existent computer security threat, asking a user to delete system files f
LenKa [72]

Answer: Virus Hoax

Explanation:

A computer virus hoax is a message that warns someone of a false virus threat. It is a a chain email that encourages who ever has received the message to pass it to other people as a form of warning.

5 0
3 years ago
What is the output of the code below assuming that global variable x has value 2 and global y has value 3? def f1(): return "ab"
Lostsunrise [7]

Answer:

ababababab

Explanation:

The code above is written in python and python uses indentation .So let me rephrase the code accordingly and explain what the code really do.

Note x and y is a global variable which can be used by any of the function declared.  According to the question x and y are 2 and 3 respectively

The first block of code describes a function f1 without any argument but the code should return the string "ab"

def f1():

      return "ab"

The second block of code defines a function f2 and returns the value of f1 multiply by x. This means you are multiplying the string "ab" by 2 which will be equals to abab

def f2():

           return f1() * x

The third block of code declared a function f3 and returns the sum of  f2 and product of f1 and y. using PEMDAS principle the multiplication aspect will be solved first so, ab × 3 = ababab, then we add it to f2  . ababab + abab = ababababab.

def f3():

        return f2() + f1() * y

Finally, we print the function f3 value to get ababababab

print(f3())

If you run the code on your IDE like below you will get  ababababab

x = 2

y = 3

def f1():

      return "ab"  

def f2():

      return f1() * x  

def f3():  

      return f2() + f1() * y  

print(f3())

     

7 0
3 years ago
Discuss four uses of computer ​
PtichkaEL [24]

1. It helps to the development of our career.

2. Through the internet, we can know the facts which were happening all over the world

3. Computer can be use as a calculator too

4. We can store any kind of information.

<h3>Hope This Helps You ❤️</h3>
6 0
3 years ago
Read 2 more answers
CP/IP over Ethernet supports basic frames with a total size of up to 1518 bytes (including both the message payload and headers)
Ne4ueva [31]

Answer:

I think you just add all the Bytes together

6 0
3 years ago
Why is it that even though there aren't the max number of answers on a question, (or sometimes even NO answers) When I click the
maks197457 [2]
It has happened to me before. i think it’s just because someone is already typing an answer maybe ‍♀️ or try restarting the app and get back on it. might be jus a glitch from the app but either way hope you get it fixed :)
4 0
3 years ago
Other questions:
  • A Chief Information Officer (CIO) recently saw on the news that a significant security flaws exists with a specific version of a
    5·1 answer
  • Write a recursive function, len, that accepts a parameter that holds a string value, and returns the number of characters in the
    7·1 answer
  • The flowchart shape for input or output is an oval. <br> a. True <br> b. False
    6·1 answer
  • Write a program for any element in keysList with a value greater than 50, print the corresponding value in itemsList, followed b
    6·1 answer
  • PSEUDOCODE PRACTICE!!! NEED HELP IMMEDIATELY!!! FIRST ANSWER GETS BRAINLYEST!!!
    12·1 answer
  • who will follow me on tiktok and like all my videos? if you do ill give branlist and give u a shoutout and you can enter my big
    15·1 answer
  • Without a/an ________. a computer is useless
    14·1 answer
  • Fear and superstition were swept away as scientists began to understand natural phenomena, leading to a shift in content for gra
    5·1 answer
  • HELP!!!<br> THIS HAPPENS EVERY TIME
    6·2 answers
  • 8. Explain strategies employed by the operating system to ensure safety of programs and data in
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!