Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Static class 1

Status
Not open for further replies.

Nosferatu

Programmer
Jun 9, 2000
412
0
0
RO
Hey there!

I am writing a library which has to have a static class (or a singleton) and i am having troubles figuring how's that done.

I have declared my class in a header file, made it static and, where i am using it, i specify the "extern" modifier to the variable, and everithing is OK.

The problem is that, when i am linking the library to another project, i find out that, the constructor for the library really gets called about 15 times, so i am a bit confused about this. I am getting the feeling that an instance of the class was created whenever the header file in which is declare is included in another file, although i specified the #ifndef _this_header_file_blah_blah... stuff.

So, could somebody point me in the right direction of doing this?

Thank you! [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
Multzam thanks alot Ady! (BTW, where do you get all those funny looking icons from?) [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
Mai Nosferatu, below the input text box used to post messages there is a link named "Emoticons/Smileys".
BTW: let me know if you succeeded with your singleton class.

Picard Out B-)
 
[Data]
Dapai ca thanks again :-D Ady... It was too obvious to check it... Duuuh... X-)
Cat despre the Singleton class, aye, ivirthing went ok :)I, thank you again man!

[/Data]B-( [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top