This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: template(s) declaration with GCC3.2-7


Rade Trimceski wrote: 

> I'm trying to compile code that was written a while ago, and
> compiled just fine with gcc 2.96. GCC 3.2-7 doesn't like it at all.
:
> #include <list>
> 
> template <class _Tp>
> class LsList : public list<_Tp> {

The newer C++ standards place the STL classes, list et al, inside the 'std'
namespace.

This means you can either address it in full:

    class LsList : public std::list<_Tp> {

or import the elements you need from the std namespace:

    #include <list>
    using std::list;

or import the std namespace wholesale:

    #include <list>
    using namespace std;

In header files, I prefer the first since you're not polluting the global
namespace of source files that include the header. In C++ sources (.cpp,
.cc, etc.) I prefer the second form since it's more precise but lots just
use the third because it's simplest. But this is just a matter of style so
use whichever suits you.

Hope that helps,
Rup.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]