Question: I have used initialization lists a great deal in my C++ programs but wasn't aware that you could allocate memory within them.

So you can do something (as a contrived example) like this:

```
class Test
{
private:
    int* i;
    int* j;
    int count;
    int* k;

public:
    Test(void) : i(new int), j(new int[10]), count(10), k(new int[count])
    {
    }

    ~Test(void)
    {
        delete i;
        delete [] j;
        delete [] k;
    }
};

```

Are there any issues in doing memory allocation in this way? Regarding the order of initialization here is it safe to have a parameter initialized by one initialized in the same list? i.e. as I allocate `count` before I use it is it safe to use or is there some special initialization order I could fall foul of?

Answer: 
This code could leak memory in the presence of an initializer that throws an exception.

Note that this could be made to work correctly if the members of `Test` were smart -- rather than raw -- pointers.
Suppose that you have:

```
class Foo
{
public:
    T* p1;
    T* p2;

    Foo()
    : p1(new T),
      p2(new T)
    {
    }
};

```

If initializing `p2` fails (either because `new` throws an out of memory exception or because the `T` constructor fails), then `p1` will be leaked. To combat this, C++ allows using `try`/`catch` in initialization lists, but it's usually pretty gross.