Click here to Skip to main content
14,978,924 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I am looking for a way to use template to do what the c# list does
I don't need complete code becouse I got a old c++ book that does a example
On dynamic mmemory with an int but not like the c# list.

Thanks for the answers.
Richard MacCutchan 15-Oct-10 13:43pm
My answer stands, check out the link.
Richard MacCutchan 16-Oct-10 5:06am
Mixing managed and unmanaged code is not for the faint hearted; I would suggest you stick with one or the other uless absolutely necessary.
ryan20fun 17-Oct-10 5:44am
Okey I'm going to try out the std::list, I want it to operate like the clr list
In that it works by a type you specify, but when I tried to do that useing a template to crate an array I got error about it,
Any way I wanted one list like storage class and not a new one for each data type
I wanted to group together

What's wrong with the C++ list[^]?
ryan20fun 15-Oct-10 13:22pm
I forgot to mentionthat I am codeing in
Win32 c++
ryan20fun 16-Oct-10 1:38am
I am writeing unmanaged code,
And I've done a quick try to mix the two
But the compiler dident like it
If you want a list in C++ then use std::list. Full stop, end of story UNLESS you've got a requirement that makes it unsuitable (i.e. you've a performance problem).

From what you've said I'm not sure you know what your requirements are - perhaps if you could explain them a bit clearer someone could offer you a solution to your problem.


I see your requirement is elusive. You need to use template, that can dynamically allocated elements. But what about data type? Do you want it to be allocated by container (like list), or you just put references/pointers to the list, and manage the memory yourself.

On the other side, it is also unclear if you are compiling with /clr or not. Are you attempting/trying to mix managed and unmanaged stuff?

You may like to use STL/CLR list, vector, which are mostly similar to STL's container classes with same name.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900