Question: Does doing something like this use dynamic memory allocation?

```
template <class T, int _size> 
class CArray 
{ 
public:
    ... 
private:
    T m_data[_size]; 
};

```

Can someone explain to me what's going on behind the scenes when I create the object?

```
CArray<SomeObject, 32> myStupidArray;

```

Answer: 
No, it does not use dynamic memory allocation. The compiler knows how much memory needs to be allocated, it is decided at compile-time, not at run-time.

It does not make any sense to explain C++ templates here, they are explained pretty well at other pages, like in the [C++ faq lite](http://www.parashift.com/c++-faq-lite/templates.html#faq-35.1).
The size of the array is known at compile time, so no, it won't be using dynamic memory allocation here. If you declare the array in a function scope then it'll be put on the stack just like any other type of object.

When you define variable-sized objects like this, what's really happening is that the compiler is building a class definition 'to order'. You'll just be using a class definition that contains 'T m\_data[32]' in it.