-
-
Save VessoVit/7279846 to your computer and use it in GitHub Desktop.
simple example of using vectors to hold references to subclasses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Boid { | |
}; | |
class First : public Boid { | |
}; | |
class Second : public Boid { | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//testApp | |
vector<Boid*> boids; | |
........ | |
Boid boids; | |
First first; | |
Second second; | |
boids.push_back(&boids); | |
boids.push_back(&first); | |
boids.push_back(&second); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment