The insert function int the arrayList is not working...d[count] = v is giving garbage.I am unable to find the problem.Can anybody please help.

class ArrayList
{
private:
    int count;
    int *d;


public:

    ArrayList(int size=2)
    {
        d=new int[size];

        count = 0;
    }

void insert (int r)
    {
        d[count] = r;
        count++;

    }

    };

    int main()
{

    ArrayList col;
    col.insert(5);      
    col.display();
    return 0;
}
Member Avatar for iamthwee

why not use a std::vector?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.