[Solved] Please explain the following C++ class definition [duplicate]


A (int n = 0) : m_n(n) {}
//           ^^^^^^^^^^

It is called the member-initialization-list.

In the definition of a constructor of a class, it specifies initializers for direct and virtual base subobjects and non-static data members.

For example in:

A (int n = 0) : m_n(n) {}

Here, your constructor of the A class initializes m_n with n.

Take a look here.

solved Please explain the following C++ class definition [duplicate]