473,386 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Constructors, Destructors and Resource Management

Dear all
Hi
As you know constructor is a member function with several missions and
one of them is "acquiring a resource" and in the same token destructor
"releases the resource". Usually after such descriptions, It is said,
the resource is like memory, file, lock, semaphore, ... As a matter of
fact, resource isn't confined to memory and constructor/destructor do
more than just memory management. I reviewed most of the major books
and papers about C++, but I can't find good examples of untrivial
resource management like lock, semaphore.
would you please make some examples for untrivial resource management.
Do you know the systems/codes/papers that describe such things?

Regards
Saeed Amrollahi
Oct 8 '08 #1
1 1734
On Oct 8, 10:17*am, ebony.s...@gmail.com wrote:

As you know constructor is a member function with several missions
Constructor has but one purpose, which is to initialise an object.
What exactly constitutes initialisation depends on the nature of the
object.
and
one of them is "acquiring a resource" and in the same token destructor
"releases the resource". Usually after such descriptions, It is said,
the resource is like memory, file, lock, semaphore, ... As a matter of
fact, resource isn't confined to memory and constructor/destructor do
more than just memory management.
IMHO, Resource Acquisition Is Initialisation (aka RAII) is a misnomer
because it does not really matter whether a resource is acquired in
constructor or later on. What does matter is that the resource is
released in the destructor.
I reviewed most of the major books
and papers about C++, but I can't find good examples of untrivial
resource management like lock, semaphore.
would you please make some examples for untrivial resource management.
Do you know the systems/codes/papers that describe such things?
http://www.boost.org/doc/libs/1_36_0...ml/thread.html
http://en.wikipedia.org/wiki/C_0x#Threading_facilities

--
Max
Oct 8 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Rajesh Garg | last post by:
Can we have private constructors and destructors? IF yes what is the use of such constructors or destructors.....in the sense where can these be implemented in a system................. I have...
8
by: johny smith | last post by:
If I have a simple class with say a couple of integers only is there any need for me to provide a destructor? thanks!
3
by: Amit | last post by:
is there anything like static constructors or destructors in C++ ? if yes, how to implement it? Thanks, Amit.
3
by: rahul8143 | last post by:
hello, I write a following program and have problem in understanding constructors and destructors. #include <iostream.h> class vector { public: double x; double y;
26
by: Michi Henning | last post by:
I've been having problem with destructors in the context of having ported C# code developed under .NET to Mono. What happens is that, on a dual-CPU machine, various parts of the code crash randomly...
8
by: Edward Diener | last post by:
I have a __value class which uses some legacy C++ code. So I wrapped the legacy C++ code in another __nogc class and have a pointer to that class as a member of my __value class. When the __value...
5
by: ElanKathir | last post by:
Hi All ! I want to know about the constructors & Destructors, constructors ---> New Destructors --> What ? (Which keyword to use for Destructor) Thanks & Regards, ElanKathir.S.N, ASM...
12
by: Joe Narissi | last post by:
I know how to create and use static constructors, but is there a such thing as a static destructor? If not, then how do you deallocate memory intialized in the static constructor? Thanks in...
21
by: Michael Hull | last post by:
Hi, I remember from somewhere reading that inlining constructors is a 'BadThing', but now can't seem to find the original source. I can't however thing of a reason why it would be for simple...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.