Class vector member initilization.
Hey!
Working with a new framework for Open GL (SFML love it so far), and I am creating a texture manager to manage the textures for any project I do in the future.
The logical way to do so was to create two vectors one to store the images one to store the TextureID handle for OpenGL. Now the Image datatype in SFML has no method to check if it has been loaded (ikr) so I am faced with a couple solutions.
1. Don't set the size of the vectors until the AddTexture(string FileName) function and have an int represent its size that is initialized as 0 in the constructor. This int will ++ immediately in the AddTexture function then the AddTexture function will resize all vectors to the size of the int.
2. I could initialize both vector's size to 1 at construction and then use a boolean to track if I have saved one object yet or not. If I have saved one object then I need to grow both methods before the function starts and if not then I will just save into the last data position of the vectors which would be 0.
The biggest danger of option 1 is that you can use a GetTexture(int index) function that if called before AddTexture(string FileName) would produce undefined behavior, but if I put a error check in the GetTexture then I could avoid this. (which it should have anyways)
Are there any other problems having vectors in a class with an uninitialized size during construction?