template question

A

alessio211734

I have a class with a Instance method to make object as unique.
I have to do many classes as it where changes are very small (class
name and internal function call). I thinks to do this with templates.
My problem is the method Instance can be a problem because
instantiation template refer to itself object. How can do it with
template?I need to make several object where every object have his
instance.

My class structure:

class P
{

P();
void Instance();
void Get();
void Set();


}


Thanks.
 
V

Victor Bazarov

I have a class with a Instance method to make object as unique.
I have to do many classes as it where changes are very small (class
name and internal function call). I thinks to do this with templates.
My problem is the method Instance can be a problem because
instantiation template refer to itself object. How can do it with
template?I need to make several object where every object have his
instance.

My class structure:

class P
{

P();
void Instance();
void Get();
void Set();


}

What you might want to google for is "singleton implemenatation C++
template". This topic is brought up every now and then, and the
solutions most likely have already been found. Now all you need is
to found *them*. Search the archives for this newsgroup and for
'comp.lang.c++.moderated' as well.

V
 

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

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top