472,805 Members | 834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

what are static destructors? disadvantages? .. TIA

2 6720
<so*****@somedomain.net> wrote...


IIUIC, a "static destructor" is a static member function of the class
that accepts one argument - a pointer to the object of that class to
be destroyed. It is probably used along with "a factory method", when
there is a need to restrict the creation of instances of some class to
free store only and/or perform additional steps before or after
creation of an object. Similar steps may need to be taken before
and/or after destroying an instance. That's that the "static
destructor" is for. I don't think it is proper to use those words
without double quotes since there is no real destructor that is static,
it's only a pretend destructor.

Disadvantages? Compared to what? To a non-static (real) destructor?
Hmm... I am looking for a good analogy here... What are the
disadvantages of a sorted collection versus non-sorted one? Can you
answer that question? Every idiom has its application. Advantages or
disadvantages, you often just have to use a certain idiom. I guess I
am simply trying to avoid answering that question. I really just
don't see it as valid.

V
Jul 22 '05 #2
Victor,

Thanks for your reply. I am a newbie, so was curious at the very
notion of "static destructor". Thanks again.

cheer.
K.

On Wed, 18 Aug 2004 00:55:35 GMT, "Victor Bazarov"
<v.********@comAcast.net> wrote:
<so*****@somedomain.net> wrote...


IIUIC, a "static destructor" is a static member function of the class
that accepts one argument - a pointer to the object of that class to
be destroyed. It is probably used along with "a factory method", when
there is a need to restrict the creation of instances of some class to
free store only and/or perform additional steps before or after
creation of an object. Similar steps may need to be taken before
and/or after destroying an instance. That's that the "static
destructor" is for. I don't think it is proper to use those words
without double quotes since there is no real destructor that is static,
it's only a pretend destructor.

Disadvantages? Compared to what? To a non-static (real) destructor?
Hmm... I am looking for a good analogy here... What are the
disadvantages of a sorted collection versus non-sorted one? Can you
answer that question? Every idiom has its application. Advantages or
disadvantages, you often just have to use a certain idiom. I guess I
am simply trying to avoid answering that question. I really just
don't see it as valid.

V


Jul 22 '05 #3

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

Similar topics

3
by: Amit | last post by:
is there anything like static constructors or destructors in C++ ? if yes, how to implement it? Thanks, Amit.
13
by: Adam H. Peterson | last post by:
I just made an observation and I wondered if it's generally known (or if I'm missing something). My observation is that static protected members are essentially useless, only a hint to the user. ...
0
by: Joanna Carter \(TeamB\) | last post by:
Following on from the other discussion, I have to just check something out with reference to disposal of resources held in static fields. I have a Persistence Framework that is 'globally...
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...
24
by: kalamantina | last post by:
#include "stdafx.h" #include <stdio.h> #define output( x ) printf( #x "\r\n" );fflush( stdout ) class CMyBase { public: CMyBase() { output( CMyBase() ); f(*this);
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
4
by: Morgan Cheng | last post by:
In C#, we can initialize static member variables in static constructor. Now, when to destruct these static member variables? If these variables hold external reference(e.g. log file stream), it is...
3
by: donna.lenharth | last post by:
Hello, I am debugging a C++ application that was ported from PostgreSQL to DB2 UDB (v8.1.0.112) on Linux and have run across a problem. We have a singleton object that handles connection...
8
by: jayaramganapathy | last post by:
Hello friends, I have a map like std::map< std::string , std::map<std::string, std::string>* EpPropCache::propertyCache ; (This is a static instance and taken from *.cpp file) As you can see...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.