Results 1 to 4 of 4

Thread: What's the reason for mentioning the <T> in the definition of a template member

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    248
    Thanks
    91
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default What's the reason for mentioning the <T> in the definition of a template member

    Why is the syntax of a template member definition written in the following way -
    Qt Code:
    1. template <typename T>
    2. MyList<T>::push_back(T & value) { ... }
    To copy to clipboard, switch view to plain text mode 
    and not
    Qt Code:
    1. template <typename T>
    2. MyList::push_back(T & value) { ... } // why can't it be MyList:: instead of MyList<T>::
    To copy to clipboard, switch view to plain text mode 
    Is there any reason for the usage of <T> immediately after the class name?
    Thanks.
    Last edited by rawfool; 20th November 2017 at 17:54.

Similar Threads

  1. Replies: 2
    Last Post: 10th October 2014, 09:49
  2. pass member function as argument int template function
    By bibhukalyana in forum General Programming
    Replies: 1
    Last Post: 12th March 2013, 07:05
  3. Replies: 2
    Last Post: 28th March 2012, 21:47
  4. Replies: 2
    Last Post: 20th October 2011, 15:14
  5. Replies: 3
    Last Post: 19th February 2008, 13:10

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.