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
A body which has three forces acting on it is in equilibrium. One force is 3N to the North and the other is 4N to the west. What us the magnitude and direction of the third force?

A: The answer to this lies actually, how they used. Along ++i(PreIncrement) the variable is incremented and new value is returned. Thus it needs one instruction to increment the va

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

Get Reverse Engineer to Linux game routine analysis Project Description: I want a fast and efficient reverse engineer with good knowledge of assembly x86 language, strong rev


The break statement The break statement, which was already covered in the switch.. case, can also be used in the loops. When a loop statement is encountered in the loops the co

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

(a) Write a recursive procedure (digits n) that computes the number of digits in the integer n using a linear recursive process. For example, (digits 42) should return 2 and (digit

Converting Base Type to Class Type (char to string)   class String { char *name; int length; public: String(void) {length =0; name = new char[length+1];

Why shouldn't Matrix class's interface look like an array-of-array? A: Some people build a Matrix class that has an operator[] that returns a reference to an Array object (or po