Thread: template variables in function calls

  1. #1
    Registered User
    Join Date
    Nov 2007

    template variables in function calls

    Hi, I know that templates are precompile commands but still I was wondering if there is a way to use template class variables ( pointers or something ) in function calls without having to provide the template arguments?

    Somenthing like this:

    template< int S >
    class foo
        int size = S;
    class bar
        foo< 20 > abc;
        void      Set_Data( foo* def )
              if( abc.size < def->size )
        foo*     Get_Data()
             return &abc;

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    No. The template parameters are part of the type. You can't omit them. Except for one case: a class template may omit them when referring to its own, current instantiation.
    All the buzzt!

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  2. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  3. Specialising a member function with a template template parameter
    By the4thamigo_uk in forum C++ Programming
    Replies: 10
    Last Post: 10-12-2007, 04:37 AM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  5. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM