How to store instanses of a template class?



 DEVELOP > c-Plus-Plus > How to store instanses of a template class?

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: ""
Date: 12 Nov 2003 05:58:05 PM
Object: How to store instanses of a template class?
I have a template class, say template<typename T> class A {...}. Now,
in the program I instantiate several As of different types: A<int>,
A<double>, A<string> etc. How can I store them in a container?
Thanks.
.

User: "Siddhu T Nalwad"

Title: Re: How to store instanses of a template class? 12 Nov 2003 11:18:44 PM
wrote in message news:<3d9e3b00.0311121558.7a818895@posting.google.com>...

I have a template class, say template<typename T> class A {...}. Now,
in the program I instantiate several As of different types: A<int>,
A<double>, A<string> etc. How can I store them in a container?

Thanks.
Make use of Standard Template Library (STL)

.

User: "Siddhu T Nalwad"

Title: Re: How to store instanses of a template class? 12 Nov 2003 11:19:20 PM
wrote in message news:<3d9e3b00.0311121558.7a818895@posting.google.com>...

I have a template class, say template<typename T> class A {...}. Now,
in the program I instantiate several As of different types: A<int>,
A<double>, A<string> etc. How can I store them in a container?

Thanks.
Make use of Standard Template Library(STL)

.

User: "Rolf Magnus"

Title: Re: How to store instanses of a template class? 12 Nov 2003 07:55:49 PM
wrote:

I have a template class, say template<typename T> class A {...}. Now,
in the program I instantiate several As of different types: A<int>,
A<double>, A<string> etc. How can I store them in a container?

You can't. They are distinct types that don't have anything to do with
each other, at least for the compiler. You can put pointers to them
into a container if you derive them all from a common polymorphic base
class.
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER