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

Ask question #write statement that assign random integer to the varaible n in the (100

What is Virtual Destructor? Describe it.


Using your mountain project source code as a starting point, you are to write a code that randomly chooses one of the triangles on the surface of your mountain, this will be the en

How do I create two functions: one to put a collection of criteria into normal form, and one to compute the score of a document. A collection of criteria will be represented using

Damjibhai and Shamjibhai are two jeweler friends. They decide to play a simple game. The game comprises of removing the jewels for polishing, turn by turn. Once a jewel is removed

(RationalNumber Class) A rational number is a number that can be represented as the quotient of two integers. For example, 1/3, 5/7, 7/2, and so forth are rational numbers (By 2/1

Operation on String - C ++ Program: Write a program to define operations on string in c++. class String {    char *char_ptr;   // pointer to string contents    int le

Member Functions of a Class A member function of the class is similar as an ordinary function. Its declaration in a class template must explain its return value as well as the