.NET "ArrayList" equivalent in unmanaged C++

Posted on 2006-05-06
Last Modified: 2008-01-09

I'm trying to find out if there is a way to implement an ArrayList class in unmanaged c++ (Linux) , that has the same methods, add, insert, remove, contains, count, etc.

I've been using C# on Windows for a 3D project i am working on, but i want it to be cross-platform, and currently there are no production ready .NET engines that work with Mono and also support OpenGL. There are a few C++ engines that are cross-platform and i am contemplating re-learning C++ (havnt used it in several years since i started programming again). But i've already gotten use to the nice features of the .net framework. it would be easier if/when mono supports managed c++, but who knows when that will be ready.

Thanks in advance for any help.

PS, please provide detailed examples, as i am still re-learning C++. thanks.
Question by:RepriseMIS
    LVL 8

    Expert Comment

    Heve you considered usage of STL (Standard Template Library) ?
    It has many container classes like map, vector, queue, ..., algoritms that operates on these containers & so called iterators that allow algoritms to access data in containers.
    LVL 86

    Accepted Solution

    In fact, if you compare to or you'll find a lot of similarities. The code using ArrayList can be rewritten to be

    #include <iostream>
    #include <list>
    #include <string>
    using namespace std;

    void PrintValues(list<string>& rlst);

    void main () {

        list<string> lst;


        cout << "lst" << endl;
        cout << "Count :" lst.size() << endl;

    void PrintValues(list<string>& rlst) {

        list<string>::iterator i;

        for (i = rlst.begin(); i != rlst.end(); ++i) {

            cout << *i << endl;


    #include <iostream>
    #include <vector>
    #include <string>
    using namespace std;

    void PrintValues(vector<string>& rlst);

    void main () {

        vector<string> vec;


        cout << "vec" << endl;
        cout << "Count :" lst.size() << endl;

    void PrintValues(vector<string>& rvec) {

        vector<string>::iterator i;

        for (i = rvec.begin(); i != rvec.end(); ++i) {

            cout << *i << endl;

    If you feel like staying with MS' libraries, there is also 'CArray' and 'CList', see e.g.
    LVL 48

    Expert Comment

    You can write wrapper using STL list<void*> to make emulation of ArrayList.
    To emulate .NET 2.0 List<> which continues ArrayList with generics, use template class with list<T>.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
    The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now