public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* template(s) declaration with GCC3.2-7
@ 2003-04-22 16:34 Rade Trimceski
  2003-04-22 16:48 ` John Love-Jensen
  0 siblings, 1 reply; 6+ messages in thread
From: Rade Trimceski @ 2003-04-22 16:34 UTC (permalink / raw)
  To: gcc-help

Hey guys (and girls if there are any) :)

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. Here's the
code as I extracted it from the header file:

[rtrimces@Vaio tests]#cat template_test.cpp
#include <list>

template <class _Tp>
class LsList : public list<_Tp> {
public:
	typedef list<_Tp> baseList;
	LsList() : baseList() {}
	LsList(const _Tp& x) : baseList(1, x) {}
	void eraseAll() {
		baseList::erase(begin(), end());
	}
	LsList<_Tp>& operator= (const LsList<_Tp> & x) {
		return (LsList<_Tp> &)baseList::operator= (x);
	}
};

When trying to compile I get the following errors:
[rtrimces@Vaio tests]# g++ -o template.o template_test.cpp
template_test.cpp:4: parse error before `<' token
template_test.cpp:7: ISO C++ forbids declaration of `LsList' with no
type
template_test.cpp: In function `int LsList()':
template_test.cpp:7: `int LsList()' redeclared as different kind of
symbol
template_test.cpp:4: previous declaration of `template<class _Tp> class
LsList'
template_test.cpp:4: previous non-function declaration `template<class
_Tp>
   class LsList'
template_test.cpp:7: conflicts with function declaration `int LsList()'
template_test.cpp:7: only constructors take base initializers
template_test.cpp:7: confused by earlier errors, bailing out



Can someone tell me what has changed with the compiler and why this code
doesn't compile anymore? Even better answer would be how should I write
this code in order to make it compile with gcc 3.2.

Thanks a lot!
Rade
P.S.
In case you are wondering:
[rtrimces@Vaio tests]# g++ --version
g++ (GCC) 3.2 20020903 (Red Hat Linux 8.0 3.2-7)




^ permalink raw reply	[flat|nested] 6+ messages in thread
[parent not found: <616BE6A276E3714788D2AC35C40CD18DC2AD0C@whale.softwire.co.uk>]

end of thread, other threads:[~2003-04-23 18:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-22 16:34 template(s) declaration with GCC3.2-7 Rade Trimceski
2003-04-22 16:48 ` John Love-Jensen
2003-04-22 22:37   ` More template(s) errors " Rade Trimceski
2003-04-23  0:20     ` Oscar Fuentes
2003-04-23 18:58   ` please unsubscribe claudio
     [not found] <616BE6A276E3714788D2AC35C40CD18DC2AD0C@whale.softwire.co.uk>
2003-04-22 16:44 ` template(s) declaration with GCC3.2-7 Rupert Wood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).