Click to See Complete Forum and Search --> : Templates giving problems when things get complicated


HighCommander4
April 8th, 2007, 07:04 PM
I'm having a weird problem with templates. Here's the most concise code that reproduces the error:

#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:
In member function `void Bar<X>::method()':
Line 14: expected `;' before "iter"

Paul McKenzie
April 8th, 2007, 07:31 PM
typename std::vector<Foo<X>* >::iterator iter;

Regards,

Paul McKenzie

TheCPUWizard
April 8th, 2007, 08:58 PM
Post deleted due to it being an incoorrect assumption - but the apology it originally contained stands.

HighCommander4
April 8th, 2007, 09:15 PM
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... :o

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.