Results 1 to 4 of 4

Thread: How to create a template of template

  1. #1
    Join Date
    Jul 2009
    Posts
    79

    How to create a template of template

    I like to abort creating a template class called Tab, which looks like this:
    Code:
    template < typename T >
    class Tab{
    protected :
      int t ;
      T *v ;
    public :
    // etc... 
    }
    Then I created a class called Vec as:
    Code:
    class Vec : public Tab <double>
    {
    //... 
    }
    This Vec works without problems.

    Now I would like to create a class GroupVec like this:
    Code:
    //in the .hpp 
    class GroupVec : public Tab <Vec>
    {
    ...
    }
    //in the .cpp, the constructor would
      GroupVec::GroupVec(int a, int b)
        :  Table<Vec(a)>(b)
      {
      }
    This method does not work. Is it possible to create a template of template?

  2. #2
    Join Date
    Oct 2005
    Posts
    2,393

    Re: How to create a template of template

    Is it possible to create a template of template?
    yes, there is no problem

    However this line seems to me suspicious:
    Code:
    :  Table<Vec(a)>(b)
    Can you post the code that created you the problem and also the error message?

  3. #3
    Join Date
    Jul 2009
    Posts
    79

    Re: How to create a template of template

    Thank you for your reply. Indeed, I find it weird, but I do not know how to express the idea that I would only have an object of my class GroupVec which is a Tab of b object of class Vec which themselves are large of size a.

  4. #4
    Join Date
    Oct 2005
    Posts
    2,393

    Re: How to create a template of template

    Apart from that, you can follow the example of vector (and provide an instance that will be copied to each element) and secondly, you can also ask whether, for a two-dimensional array, your structure is really adapted.

    Why, for example, not have been directly Tab <Tab <double>>? You have a special need on the control lines (or columns, it depends)

Similar Threads

  1. Replies: 2
    Last Post: 28-01-2012, 03:50 PM
  2. How to create Template button in Silverlight 2
    By Tweaker in forum Tips & Tweaks
    Replies: 2
    Last Post: 05-08-2010, 12:57 AM
  3. How to create a custom template for Visio?
    By Jacques25 in forum Windows Software
    Replies: 5
    Last Post: 21-03-2010, 01:10 AM
  4. How to Create a Template in Word
    By Maagh in forum Windows Software
    Replies: 3
    Last Post: 25-06-2009, 09:28 PM
  5. How to create template in outlook 2003
    By Techguru01 in forum Tips & Tweaks
    Replies: 1
    Last Post: 14-02-2009, 11:09 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,297,902.63886 seconds with 17 queries