I'm trying to understand POD types and how they are allocated and initialized on the stack. Given
class A {
public:
A();
int x;
};
class B {
public:
int x;
};
int func()
{
A a;
B b;
}
Am I correct in saying that b is allocated after a but initialized prior to a? By that I mean that the space is allocate for a and b in the order that they are declared but b is initialized when the space is allocated and a is initialized when it is declared?
I read a very good FAQ about PODs and Aggregated here What are Aggregates and PODs and how/why are they special?
One of the things he said is: The lifetime of objects of non-POD class type begins when the constructor has finished and ends when the destructor has finished. For POD classes, the lifetime begins when storage for the object is occupied and finishes when that storage is released or reused.
So I'm trying understand the details of how PODs are allocated and initialized and how that is different from non-PODs.