I have a class that contains a member that is a vector of floats and needs to be available to all objects of the class. The size of the member won't be known until runtime and I can't figure out how to set the size of the vector.

My first try was to try to set the size in the constructor, but that just memory all messed up. *numScores* is the number of scores to create that is only known at runtime.

```
class Window
{
public:
    Window ();

private:
    vector<float> mScores;
};

vector<float> Window::mScores;

Window::Window ()
{
    mScores.resize (numScores);
}

```

I tried setting the size in the member initialization section of the constructor:

```
class Window
{
public:
    Window ()

private:
    vector<float> mScores;
}

vector<float> Window::mScores;

Window::Window ()
    : mScores (numScores)
{
}

```

and got the following error `"'std::vector<float, std::allocator<float> > Window::mScore' is a static data member; it can only be initialized at its definition"`

So, I moved the setting of the size to where mScores is defined:

```
class Window
{
public:
    Window ()

private:
    vector<float> mScores;
}

vector<float> Window::mScores (numScores);

Window::Window ()
{
}

```

This compiled fine, but when I ran my program and looked at Window::mScores, the size was 0.

I've been trying to track down this problem for a couple of weeks and finally figured out today what the problem is but don't have any idea how to fix it. It would be easy if the *numScores* was known at compile-time, but unfortunately it is not.

Is there some design pattern or boost-like library that would have something that I could refer to to figure this out?

Any help would be greatly appreciated!

Edit-
Thanks for everyone's input. As I mentioned below, I made a mistake when I copied the Window class over from the computer that the code actually resides on and the compounded that by cutting and pasting the class in the other examples.

With that said, it turns out that I didn't need the static field. I'm in the process of translating FORTRAN (or Fogeytran as I've started calling it) into C++ and was very confused on how the mScores field was being used. Once I realized it wasn't being shared between Windows objects, everything fell into place and is working fine now.

Once again, thanks again for the information.