template

This is a discussion on template within the C++ Programming forums, part of the General Programming Boards category; in template prototype whats the diffirence b/w class and typename ? Code: 1 // Fig. 6.26: maximum.h 2 // Definition ...

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    164

    template

    in template prototype

    whats the diffirence b/w class and typename

    ?

    Code:
    1  // Fig. 6.26: maximum.h
     2  // Definition of function template maximum.
     3
     4  template < class T >  // or template< typename T >         
     5  T maximum( T value1, T value2, T value3 )                  
     6  {                                                          
     7     T maximumValue = value1; // assume value1 is maximum    
     8                                                             
     9     // determine whether value2 is greater than maximumValue
    10     if ( value2 > maximumValue )                            
    11        maximumValue = value2;                               
    12                                                             
    13     // determine whether value3 is greater than maximumValue
    14     if ( value3 > maximumValue )                            
    15        maximumValue = value3;                               
    16                                                             
    17     return maximumValue;                                    
    18  } // end function template maximum
    here why is template <class T> ???? whats the purpose of it ?
    Last edited by manzoor; 02-22-2008 at 07:20 AM.

  2. #2
    coder
    Join Date
    Feb 2008
    Posts
    127

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,648

  4. #4
    Registered User
    Join Date
    Nov 2007
    Posts
    164
    vgg

    man

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 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
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  4. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 04:15 AM
  5. oh me oh my hash maps up the wazoo
    By DarkDays in forum C++ Programming
    Replies: 5
    Last Post: 11-30-2001, 11:54 AM

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