A proper way to store ints to the array

A proper way to store ints to the array
0.0 0


Hello, well this is rather more c++ syntax problem. I need an array of ints. As i don’t know the size of this and on runtime i’ll need to delete some of them from middle of the array, i thought about CCMutableArray: tags = new CCMutableArray; <—- this doesn’t work, so i thought about: tags = new CCMutableArray<int*>;
But what is the proper way to store int* to this array? How do i alloc memory for this int? Is it just:

int* temp = new int; int temp2 = 4; temp = &temp2; tags->addObject(temp);

??? Or i should use other type of array for ints? For example lists? Thank you.


Good question. You can not store “int *” into “CCMutableArray”, because the type int is not a class derived from CCObject. Try to use “list” instead.


You can store CCInteger in array

arr->addObject( CCInteger::create(yourIntVar) );