Array List

Not sure how this translates from java to c++. Is there a ArrayList to handle object adding and subtracting?

ArrayList a = new Array();


Thanks, T

yes, there is the standard template library. and the vector class:

more here:



This is a second question to the ArrayList class. I want to be able to build a global Arraylist so that I can access it in any other particle. Not sure the best way to go about doing this.

i usually don’t do a global variable but a static attribute of a class.
like this:

// xyz.h  
class xyz  
  static vector<int> globalNumbers;  
   void doSomethingWithTheNumbers(); // if it doesn't access non-static attributes it could also be declared as static  
// xyz.cpp  
vector<int> xyz::globalNumbers; // this is necessary to initialize/call constructor of the static attribute  
void xyz::doSomethingWithTheNumbers();  

hmm I think im not sure how to ask the question. I drew a picture any help would be great. I am trying to make it so that one particle system (arraylist) can add particles to another particle system (array list).

I think the answer is a pointer ref to the other array list. not sure how to do that :slight_smile:

I am not exactly sure what you are trying to do but the following might help:

One of the nice things about using stl containers is that you can pass them around as references. Typically if you trying to operate on any stl container (in your case a vector) the signature of the method would look like this:

void doSomethingToParticals( vector& particles );

Similarly you can have a list of particle systems and pass them around:

void doSomethingToParticalSystems( vector& psys );

(If you don’t use the little ‘&’ they will be copied on each pass.)

hope that helps,

one quick little tip is to use instead of , just personal preference.

but perhaps more to your question, have you thought about making a static instance of your testApp.cpp (or whatever you’ve named it) and including it in whatever your particle class is? then you can call global f’ns from within the class that act upon global arrays/vectors/deques of the classes.


deque <Class1*> array1;
deque <Class2*> array2;

void testApp::fillArray1(){
array1.push_back(new Class1 () );

void testApp::fillArray2(){
array2.push_back(new Class2 () );


void Class1::dothisthing(){


void Class2::dothatthing(){

maybe that helps?


Thanks man -

That helped a ton. Basically what I did was made a class that managed all the arraylist. That object was then passed using ( & ) to all the other arraylist. Thanks again.