Flocking - subclasses

Hi all,

I’m pretty new to Open Frameworks and C++.

At the moment I’m working at an assignment for which I have to make a flocking system with different subclasses that behave different.

As a basis I us this code:
https://sites.google.com/site/ofauckland/examples/ofxflocking-example

The thing however is, that the structure of this code is different then I’m used to; making new class objects with ‘new …’

My question is, how can I use two flocking classes? To get started, first only with a different color for instance.

One of the subclasses I’ve added until now is this:
class Team1 : public Boid {
public:

Team1(): Boid() {};
Team1(int x, int y): Boid(x,y) {};

void draw()
{

}
};

I used a virtual void draw for the void draw of the superclass Boid and used boids.push_back(*new Team1()); in setup and and mousedrag. This gives the following errors:

  • expected type-specifier before ‘Team1’
  • expected `)’ before ‘Team1’
  • no matching function for call to ‘std::vector<Boid, std::allocator >::push_back(int&)’

I think you want this:

  
class Team1 : public Boid {  
public:  
     
  Team1() {  
    Boid();  
  };  
   Team1(int x, int y) {  
    Boid(x,y);  
  };  
     
  
     
   void draw()  
    {  
  
    }  
};  

As for push_back try this:

  
Team1 team; // just declaring the variable "runs" the constructor  
boids.push_back(team);