一种编写C++构造函数中初始化列表的格式

A Format of Writing Initialization Lists in C++ Constructors

I found a nice format writing initialization lists in C++ constructors today when I was reading the source code of CppUnit:

MyClass::MyClass(m1, m2, ..., mn) : member1(m1) , member2(m2) , ... , membern(mn) { ... }

The reason I say it's nice is because it puts the colon (:) and commas (,) at the start of each line, so that the members in the initialization list are gracefully aligned. I was used to putting the colon and the commas with their predecessors in the same line, so the Visual Studio editor would indent the initialization list as follows, ugly making all but the first member indent:

MyClass::MyClass(m1, m2, m3, ..., mn) : member1(m1), member2(m2), member3(m3), ... membern(mn) { }

Now this problem can be solved. :D

你可能感兴趣的:(C++,c,list,each,initialization)