+ Reply to Thread
Results 1 to 2 of 2

Thread: Question on C++ template

  1. #1
    Surfer is offline Senior Member
    Join Date
    Mar 2010
    Posts
    321

    Question on C++ template

    template <class T>
    T max(T a, T b)
    {
    return ( a > b )? a : b;
    }
    for built in data types it will work fine .. if we send class objects as parameters then how it will work??

  2. #2
    Surfer is offline Senior Member
    Join Date
    Mar 2010
    Posts
    321
    Class must overload the ">" operator and have an accessible copy constructor.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. template class compilation
    By JavaGuy in forum C++ Fundamentals
    Replies: 0
    Last Post: 20th June 2010, 13:10
  2. template class syntax error
    By JavaGuy in forum Bloomberg
    Replies: 0
    Last Post: 26th May 2010, 23:40
  3. template class compilation
    By JavaGuy in forum Bloomberg
    Replies: 0
    Last Post: 26th May 2010, 23:35
  4. Google Interview Question
    By TopGun in forum Google
    Replies: 0
    Last Post: 17th February 2008, 07:57

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