If one won''t explicitly call the destructor of a local then , C/C++ Programming

if one won't explicitly call the destructor of a local; then how does he handle the above situation?

Posted Date: 3/15/2013 5:26:38 AM | Location : United States





if one won''t explicitly call the destructor of a local; then how does he handle the above situation?

A: Just wrap the extent of the lifetime of the local in an artificial block {...}:

void someCode()

{

{

 

File f;

...insert code which should execute while f is still open...

} f''s destructor will automatically be called here.

...insert code here which should execute after f is closed...}

 

Posted by | Posted Date: 3/15/2013 5:27:11 AM

if one won''t explicitly call the destructor of a local; then how does he handle the above situation?

A: Just wrap the extent of the lifetime of the local in an artificial block {...}:

void someCode()

{

{

 

File f;

...insert code which should execute while f is still open...

} f''s destructor will automatically be called here.

...insert code here which should execute after f is closed...}

 

Posted by | Posted Date: 3/15/2013 5:33:02 AM


Related Discussions:- If one won''t explicitly call the destructor of a local then , Assignment Help, Ask Question on If one won''t explicitly call the destructor of a local then , Get Answer, Expert's Help, If one won''t explicitly call the destructor of a local then Discussions

Write discussion on If one won''t explicitly call the destructor of a local then
Your posts are moderated
Related Questions
What is inheritance? Class, the vehicle, which is used to execute object-oriented concepts in C++, has given a new dimension to this idea of reusability. Many vendors now offer

A conversion constructor declared with the explicit keyword. The compiler does not use an explicit constructor to execute an implied conversion of types. Its purpose is reserved ex


Write out pseudocode for a function called "and" that takes two arguments, both booleans, and returns the logical and of the inputs. DO NOT use the logical and operator: instead, w

write a simple c++ program to implement a stack: 1. push 2. pop

Define The Return Statement in Computer Programming? The return statement is used for two purposes once the return statement is executed the program control will be immediately

Should one design a classes from the outside (interfaces first) or inside (data first)? A: From the outside. A superior interface provides a simplified view which is express

i need amibroker afl to dll plugin

A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2

Define the Multi Dimensional Arrays? Consequently far we have considered arrays with only one dimension. It is as well possible to define an array which is having a 2-dimension