Question
When I write a destructor, do I need to explicitly call the destructors for my member objects?

Answers

No. You never need to explicitly call a destructor (except with placement new).

A class's destructor (whether or not you explicitly define one) automagically invokes the destructors for member objects. They are destroyed in the reverse order they appear within the declaration for the class.

class Member {
public:
~Member();
...
};

class Fred {
public:
~Fred();
...
private:
Member x_;
Member y_;
Member z_;
};

Fred::~Fred()
{
// Compiler automagically calls z_.~Member()
// Compiler automagically calls y_.~Member()
// Compiler automagically calls x_.~Member()
}   Your Comment




More Software Questions..
What is the inputsplit in map reduce software?

What is software configuration management?

What Is Java Api For Xml-based Rpc (jax-rpc)?

How can you implement fine-grained auditing?

What is IBM’s simple explanation for Big Data’s four critical features?

What is static synchronized method in JDBC API? Give an example?

What does the NULLIF function do?

What happens if a start method is not invoked and the run method is directly invoked?

Should we override finalize method

what is the difference between mysql_fetch_array and mysql_fetch_object?

How will XML affect my document links?

Why to use Style Sheets?

What are Filters in MVC?

Can you explain Application layer in OSI model?

How to define new testplan attributes?

What are the minimum system requirements to run Photoshop? Is it possible to run Photoshop over linux?

Which oracle package is used to manage the oracle lock management services?

What is Latch Up? Explain Latch Up with cross section of a CMOS Inverter. How do you avoid Latch Up?

What is marker interface?

What types of partitioning are there for BW?



Search
Can you Answer!!
  • Q Which short key is used to freeze the GUI Spy?
  • Q Where has the largest concentration of Harappan sites been found?
  • Q How do you debug and test your sas programs?
  • Q What is meant by experiments?
  • Q What is appendicular
  • Q Which of the following is used for making measuring instruments? (Invar Silumin, Magnalium, Steel)
  • Q Write brief notes on compromise?
  • Q How to create multithreaded program? Explain different ways of using thread? When a thread is created and started, what is its initial state?
  • Q Problem related to diagrams . Five diagrams were given and asked to find the sixth one.
  • Q Why is the Department setting the standard salary level at the 40th percentile of weekly earnings for full-time salaried workers in the lowest wage Census Region and not on national data as proposed?
  • Q Scenario: During a prospecting session, you encounter someone who immediately wants to know the price. If you give the price, you will lose because you are a high-priced provider, but offer significant advantages over the competition. If you don't give the price, the prospect hangs-up the phone frustrated. What do you do?