I am learning about member initializer lists in C++. So consider the following example:
struct Person
{
public:
Person(int pAge): age(pAge)
// ^^^^^^^^^ is this member initializer formally part of the constructor body?
{
}
private:
int age = 0;
};
My first question is that is the member initializer age(pAge) formally part of the constructor's body. I mean i've read that a function's body starts from the opening { and end at the closing }. To my current understanding, there are four things involved here:
- Ctor definition: This includes the whole
//this whole thing is ctor definition
Person(int pAge): age(pAge)
{
}
Member initializer: This is the
age(pAge)part.Ctor declaration: This is the
Person(int pAge)part.Ctor's body: This is the region between the opening
{and the closing}.
My second question is that is the above given description correct? If not then what should be the correct meaning of those four terms according to the C++ standard: Ctor definition, Member initializer, Ctor declaration and Ctor's body.
PS: I've read this post which doesn't answer my question.