Thread: Help with templates

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    19

    Thumbs up Help with templates

    Code:
    template <class T> class b 
    {
        T v;
        ... // code here
    };
    
    int main()
    {
        b<b<int>> *C;
        ...
    }
    Some C++ compilers accept this code and others not.
    Can somebody give me an alternative to my code or some sugestions ?

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Code:
    b<b<int>> *C;
    In the current C++ standard, that ">>" should be seen as a right-shift operator, not as two ">"s. I believe in the next standard, that will be valid syntax, but right now, you should have to use "> >".
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Templates from DLL or static library problem
    By mikahell in forum C++ Programming
    Replies: 2
    Last Post: 01-01-2008, 01:49 AM
  2. Questions about Templates
    By Shamino in forum C++ Programming
    Replies: 4
    Last Post: 12-18-2005, 12:22 AM
  3. templates and inheritance problem
    By kuhnmi in forum C++ Programming
    Replies: 4
    Last Post: 06-14-2004, 02:46 AM
  4. When and when not to use templates
    By *ClownPimp* in forum C++ Programming
    Replies: 7
    Last Post: 07-20-2003, 09:36 AM