J
Jim Langston
What I want to do: have a vector of ints in my class initialized with 0 to
499 which will later be pushed/popped out of the vector by instances.
What I have:
class CParticleStream // Yes, I know you wouldn't use 'C'
{
private:
static std::vector<int> PSArray;
public:
CParticleStream(void);
~CParticleStream(void);
};
Now, my understanding is if it was a simle variable, such as an int I would
only have to do:
CParticleStream::MyInt = 0;
Since this is a vector and I need a for loop I can't do that outside a
function body.
I'm looking at having to create *another* variable, such as a bool
initialized, initialize it to false, then in my constructor if initialized
is false load my vector and set initialized to true.
Is there some other way to do this without having to use a second variable?
I could also make it a public method and initialize it at the top of main,
but only this class will be using this vector.
I can't simply look for a size of 0 becuase this vector can shrink in it's
lifetime and may shrink down to 0 (and it does not need to be initalized
then).
Incidently, what is a static class member called? Simply a static class
member?
------------------------------------------------
Why I actually need this: I'm using a DirectX engine that has "particle
streams" that you reference via an int index, 0 to 499. Internally to the
engine there is an array of 500 elements that this index references.
Particle streams will come and go and I need some method of keeping track of
which ones are used and which ones are available.
If someone could think of a better way to do this I'm all ears.
Thanks.
499 which will later be pushed/popped out of the vector by instances.
What I have:
class CParticleStream // Yes, I know you wouldn't use 'C'
{
private:
static std::vector<int> PSArray;
public:
CParticleStream(void);
~CParticleStream(void);
};
Now, my understanding is if it was a simle variable, such as an int I would
only have to do:
CParticleStream::MyInt = 0;
Since this is a vector and I need a for loop I can't do that outside a
function body.
I'm looking at having to create *another* variable, such as a bool
initialized, initialize it to false, then in my constructor if initialized
is false load my vector and set initialized to true.
Is there some other way to do this without having to use a second variable?
I could also make it a public method and initialize it at the top of main,
but only this class will be using this vector.
I can't simply look for a size of 0 becuase this vector can shrink in it's
lifetime and may shrink down to 0 (and it does not need to be initalized
then).
Incidently, what is a static class member called? Simply a static class
member?
------------------------------------------------
Why I actually need this: I'm using a DirectX engine that has "particle
streams" that you reference via an int index, 0 to 499. Internally to the
engine there is an array of 500 elements that this index references.
Particle streams will come and go and I need some method of keeping track of
which ones are used and which ones are available.
If someone could think of a better way to do this I'm all ears.
Thanks.