help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: g++ error : Nested template classes


From: Paul Pluzhnikov
Subject: Re: g++ error : Nested template classes
Date: 02 Feb 2005 17:59:27 -0800
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Artificial Intelligence)

"BJP" <patel3@gmail.com> writes:

> when I try to build using gcc 3.3.2, it gives me error on Line: 11
> saying "shadow class T"

Here is what 'edgcpfe --strict junk.cc' has to say about it:

"junk.cc", line 11: error: template parameter "T" may not be redeclared in
          this scope
   template <class T>             //Line 11: error line 
                   ^

1 error detected in the compilation of "junk.cc".

> Any Idea why, works with Visual Studio C++.

Visual C++ is very bad as far as standard conformance is concerned.
You should not trust it to flag invalid code as such. It is
especially lax at templates, and will compile happily the following:

$ cat junk.cpp
 template <class T> class Foo {
  any gargbage you wish to put in here   // literally that garbage
 }; 

$ cl /c junk.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.

junk.cpp
$ echo $?
0

> Question is do I have to change all instance of "T" to "Z" 

Yes.

Cheers,
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]