[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Template bug?
From: |
address@hidden |
Subject: |
Re: Template bug? |
Date: |
Thu, 21 Jan 2010 14:22:30 -0800 (PST) |
User-agent: |
G2/1.0 |
On Dec 7 2009, 9:07 am, Ben Abraham <address@hidden> wrote:
> Ben Abraham
> 629 East Fifth Street Apt. 20
> New York NY 10009
>
> Hi,
>
> There may be bug with respect to templates in g++. The below
> program does not compile. It may be some silly mistake on my part. I've
> included the diagnostic and version information respectively.
>
> Sincerely,
> Ben
>
> #include <vector>
>
> using namespace std;
>
> template <class T>
> class TTable1 {
> T fType;
> public:
> void debug() {
> vector<T>::iterator it; //this is the line in question (10)
> }
>
> };
>
> int main() {
>
> }
>
> $ g++ testTemplate.cpp
> testTemplate.cpp: In member function `void TTable1<T>::debug()':
> testTemplate.cpp:10: error: expected `;' before "it"
>
> $ g++ --version
> g++ (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)
> Copyright (C) 2004 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions. There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
> It's cygwin version above running on Windows XP Professional.
> Version 5.1 (Build 2600.xpsp.050928-11517 : Service Pack 2 (Windows
> version)
Ben
You need to prefix your 'vector<T>::iterator it' declaration with
'typename ' to inform gcc that this is your intention:
typename vector<T>::iterator it;
That should solve your problem.
Rgds
Paul
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Template bug?,
address@hidden <=