[Dev-C++] Re: Dev-cpp-users digest, Vol 1 #1223 - 11 msgs
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Dave R. <eb...@eq...> - 2003-01-12 12:01:26
|
Hi There
The code you posted fils because B() member function is undefined so change
this:
#include <set>
template <class T>
class A
{
public:
A();
B();
std::set<T> _list;
};
to this
#include <set>
template <class T>
class A
{
public:
A();
void B();
std::set<T> _list;
};
and it should work fine. In C++ class definitions only constructors and
destructors have no return type. In your case member A() is the constructor
for class A ( becuase of its name ), and member B() is an "ordinary" member
and _needs_ to have a type declared.
Hope this helps
Regards
Dave
> Message: 11
> From: "erwan ancel" <erw...@fr...>
> To: <dev...@li...>
> Date: Sun, 12 Jan 2003 11:26:01 +0100
> Subject: [Dev-C++] templates in C++ : precisions
>
> well, this is my problem:
>
> I would like to make a template class that owns a set of elements that
have
> the type of one of the class parameters. And it doesn't compile...
> example:
>
> #include <set>
> template <class T>
> class A
> {
> public:
> A();
> B();
> std::set<T> _list;
> };
>
> the compiler's output tells that the type T is not defined... Well, of
> course, but it will be defined when the template will be instanciated. So
it
> should be possible...
> Does anybody know a solution to my problem?
>
>
>
>
> --__--__--
>
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>
> End of Dev-cpp-users Digest
>
|