| 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.
.
|
|
|
|

|
Related Articles |
|
|