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: 
You are allocating memory in your initialiser-list; this is totally fine, but you are then assigning the pointers to that memory to raw pointers.

These raw pointers do not imply any sort of memory ownership or deletion of the pointers that they point to, and as a result, the code contains several memory leaks, does not follow the "Rule of Five", and is generally bad.

A far better way to write `Test` would be:

```
class Test
{
private:
    //Assuming you actually want dynamic memory allocation:
    std::unique_ptr<int> i;
    std::unique_ptr<int[]> j;
    int count;
    std::unique_ptr<int[]> k;

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

```
Steve Jessop's answer presents pitfalls. 

About the order, which I think is what your question addressed:

> 
> 12.6.2/4
> 
> 
> Initialization shall proceed in the following order:
> 
> 
> [...]
> 
> 
> * Then, nonstatic data members shall be initialized in the order they were declared in the class definition (again regardless of the order
>  of the mem-initializers).
> 
> 
> 

Since in your class, `count` is declared before `k`, you're ok.