In fact, the content after the colon is the initialization of the member list, there are generally three kinds of situations:
1. Initialize the object that contains the object member, for example,
Class line has two private object members StartPoint, Endpoint,line's constructor written:
Line (int sx,int sy,int ex,int ey): StartPoint (Sx,sy), endpoint (Ex,ey) {...}
The constructors of the respective objects are called separately in the order of the object members in the class definition, and then their constructors are executed.
2, for objects without object members, the initialization can also be applied to the above format, for example,
The class rectangle has two data members of length, width, and its constructors are written as:
Rectangle (): Length (1), Width (2) {}
Rectangle (int x,int y): Length (x), Width (y) {}
3. Initialize the parent class , for example,
The parent class of CDLGCALCDLG is the MFC class CDialog, whose constructor is written as:
Cdlgcalcdlg (cwnd* pparent): CDialog (Cdlgcalcdlg::idd, pparent)
Where IDD is an enumeration element, the ID of the flag dialog template
Initializing an object with an initialized member list is sometimes necessary, sometimes for efficiency reasons
http://ivan4126.blog.163.com/blog/static/209491092201301534928785/
C + + constructor plus colon