473,396 Members | 1,940 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,396 software developers and data experts.

Meyers-Singleton

hello group,

is there a problem with meyers-singleton when defined in header-file?

example (someheader.h):

class a
{
static a& Instance() {static a instance; return instance;}
}

or can a static member not be implicit inline?

thx & hand, chris
Dec 13 '07 #1
2 2985
Alf P. Steinbach schrieb:
* Chris Forone:
>>
is there a problem with meyers-singleton when defined in header-file?

No.

>example (someheader.h):

class a
{
static a& Instance() {static a instance; return instance;}
}

If the class definition was corrected by adding the required semicolon,
the Instance member function would still be inaccessible because it's
private.
i have Instance() public, and semicolon in place...
>
If the above was not your actual code, then please read the FAQ item on
how to post a question about code that does not work.
no, i have written it... next time i will do it better!
>
Cheers, & hth.,

- Alf
thanks a lot, chris
Dec 13 '07 #2
On Dec 13, 9:36 am, Chris Forone <4...@gmx.atwrote:
is there a problem with meyers-singleton when defined in
header-file?
example (someheader.h):
class a
{
static a& Instance() {static a instance; return instance;}
}
or can a static member not be implicit inline?
There's no problem as far as the language is concerned, but it's
a good way to make maintenance intolerable and introduce
additional source code coupling.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Dec 13 '07 #3

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

Similar topics

12
by: Fred Ma | last post by:
Hello, I was looking at Meyers's "Effective STL", item 23 about choosing between vectors and maps (at least that the choice for me). In many cases, using sorted vectors is faster for lookups. ...
4
by: John | last post by:
I am looking for a good Lock class implementation that has barely been implemented in Effective STL of Myers (Item 12). Any pointers? Is there an implementation that is good for both OpenMP and...
15
by: Peter | last post by:
I right now reading this book. And he is iterating some points I'm following since 1996, e.g. exception safety. But e.g. he is missing one of the major exception safety guidelines, which is ...
4
by: jfwfmt | last post by:
Please pardon my ignorance. I'm writing a C++ STL program after not writing code for 7 years, I'm trying to invoke key_word.inc() using an iterator for a set containing key_word_T. The following...
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: 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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.