passing unspecialised template classes as function arguments

This is a discussion on passing unspecialised template classes as function arguments within the C++ Programming forums, part of the General Programming Boards category; hi all, is there anyway to pass a (unspecialised) templated class reference through a function? something like : Code: template ...

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    50

    passing unspecialised template classes as function arguments

    hi all,

    is there anyway to pass a (unspecialised) templated class reference through a function? something like :
    Code:
    template <class TYPE> class VECTOR3 {/*etc etc*/};
    template <class TYPE> class MTRand{/*etc etc*/};
    
    
    int AFunction(VECTOR3<TYPE> v1, VECTOR3<TYPE> v2, MTRand<TYPE>);
    except that doesn't compile -

    d:\documents\comsic ray muon tomography\muon generator\muon generator\muonimagingmcsim.h(13) : error C2065: 'TYPE' : undeclared identifier

    any help with my C/C++ language bastardisation greatly appreciated!

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,344
    You can make the function templated also:
    Code:
    template <class TYPE>
    int AFunction(VECTOR3<TYPE> v1, VECTOR3<TYPE> v2, MTRand<TYPE>);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Deducing Function Template Arguments
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 03-12-2008, 08:29 PM
  2. Passing arguments to another function
    By Wiretron in forum C Programming
    Replies: 2
    Last Post: 12-24-2006, 05:57 AM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  5. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 04:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21