One Instance Question

I

Immortal Nephi

I do not have book -- Effective C++: 55 Specific Ways to Improve Your
Programs and Designs, 3/E. The programmer uses it and learns how to
write high performance code with best optimization. Can you please
tell me? Do it mention singleton object?
My goal is to create library. The clients can import library into
their source code and invoke either functions or classes.
I want to use only one instance for the lifetime throughout execution
program. Should I declare all data members and member functions to be
static in the singleton class? Do singleton benefit higher
performance? Please let me know.
 
D

DDD

        I do not have book -- Effective C++: 55 Specific Ways to Improve Your
Programs and Designs, 3/E.  The programmer uses it and learns how to
write high performance code with best optimization.  Can you please
tell me?  Do it mention singleton object?
        My goal is to create library.  The clients can import library into
their source code and invoke either functions or classes.
        I want to use only one instance for the lifetime throughout execution
program.  Should I declare all data members and member functions to be
static in the singleton class?  Do singleton benefit higher
performance?  Please let me know.

If you have a class, you just need declare a pointer to the class,
called *singleInstance=NULL
At the same time, the class should have a static funciton, you can
just named it createInstantce.
In the createInstantce method, new an instance for singleInstance if
it's null. That's all.

Higher performance is a complex problem. There is no possible to solve
the performance by one step.

Good luck!

Maybe contains nuts.
 
N

Neelesh

        I do not have book -- Effective C++: 55 Specific Ways to Improve Your
Programs and Designs, 3/E.  The programmer uses it and learns how to
write high performance code with best optimization.  Can you please
tell me?  Do it mention singleton object?

On the "InformIT" site you can find the table-of-contents of this book
to know what exactl the book contains.

http://www.informit.com/store/product.aspx?isbn=0201924889

Chapter-6 of "Modern C++ design" talks about "implementing
singletons". That could be helpful.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,160
Messages
2,570,889
Members
47,420
Latest member
ZitaVos505

Latest Threads

Top