When porting from processing I found very usefull the vectors for dealing with arrays. I think they aren´t as fast as regular arrays but they are easy to use.
at the .h
#include <vector>
class CLASSNAME{
public:
vector<particle> particles;
}
at the .cpp
for adding;
particle p = particle();
particles.push_back(p);
for itineration:
for (int i = 0; i < particles.size(); i++)
particles[i].draw();
I’ve managed to port it, but now i get a single error when building with xCode.
/Users/MP/app/src/Particle.cpp:20:0 /Users/MP/app/src/Particle.cpp:20:0 error: no match for ‘operator=’ in ‘((particle*)this)->particle::Stars. std::vector<_Tp, _Alloc>::operator[] with--Tp-=-particle,--Alloc-=-std::allocator = (((particle*)operator new(76u)), (->particle::particle(), ))’
#include "Particle.h"
#include "testApp.h"
void particle::setup(){
numParticles=200;
for (int i=0;i<numParticles;i++)
{
Stars[i] = new particle(); // < This is where i get the error
}
}