CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2004
    Location
    Canada
    Posts
    1,342

    Templates giving problems when things get complicated

    I'm having a weird problem with templates. Here's the most concise code that reproduces the error:

    Code:
    #include <vector>
    
    template <typename T>
    class Foo
    {
    };
    
    template <typename X>
    class Bar
    {
    public:
        void method()
        {
            std::vector<Foo<X>* >::iterator iter;
        }
    };
    
    int main() {}
    Dev-Cpp complains that:
    Code:
    In member function `void Bar<X>::method()':
    Line 14: expected `;' before "iter"
    Old Unix programmers never die, they just mv to /dev/null

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Templates giving problems when things get complicated

    Code:
    typename std::vector<Foo<X>* >::iterator iter;
    Regards,

    Paul McKenzie

  3. #3
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: Templates giving problems when things get complicated

    Post deleted due to it being an incoorrect assumption - but the apology it originally contained stands.
    Last edited by TheCPUWizard; April 8th, 2007 at 10:01 PM.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  4. #4
    Join Date
    Apr 2004
    Location
    Canada
    Posts
    1,342

    Re: Templates giving problems when things get complicated

    Quote Originally Posted by Paul McKenzie
    Code:
    typename std::vector<Foo<X>* >::iterator iter;
    Regards,

    Paul McKenzie
    Thank you, that does the trick. Shoukd've thought of that, but I've been away from C++ for a while, I got a bit rusty...

    Quote Originally Posted by TheCPUWizard
    Possibly incorrect, but this sounds like implementation problems already regarding the previous post about building decks of cards..... If not, I apologize in advance....
    This is completely unrelated to the other problem about Deck.
    Old Unix programmers never die, they just mv to /dev/null

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured