Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep a list of instances of a class?

I'm writing a raytracer in C++ and need to be able to check intersections with every object in a scene (optimizations will come later), and to do this, I need to keep a running list of class instances. A list of pointers, updated when a new instance is created, won't work because as far as I know there is no way to increase the size of the array after it is initialized. I'd really like a built-in (to C++) solution if there is one.

like image 281
Andrew Buss Avatar asked Dec 06 '22 02:12

Andrew Buss


1 Answers

There are any number of STL Containers you could use.

STL Container Reference

like image 91
DrDeth Avatar answered Dec 07 '22 16:12

DrDeth