template question

Discussion in 'C++' started by alessio211734@yahoo.it, Dec 12, 2007.

  1. Guest

    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.
    , Dec 12, 2007
    #1
    1. Advertising

  2. wrote:
    > 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
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Dec 12, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Theis
    Replies:
    2
    Views:
    454
    Chris Theis
    Jul 24, 2003
  2. tom_usenet
    Replies:
    0
    Views:
    524
    tom_usenet
    Jul 24, 2003
  3. Replies:
    1
    Views:
    2,084
    Gianni Mariani
    Jun 8, 2007
  4. Peng Yu
    Replies:
    3
    Views:
    754
    Thomas J. Gritzan
    Oct 26, 2008
  5. nguillot
    Replies:
    5
    Views:
    516
Loading...

Share This Page