Coding Style - C++ constructor initialization list

Boris Barbulovski bbarbulovski at gmail.com
Mon Mar 23 01:44:33 PDT 2015


or maybe like this:

*ClassName::ClassName()*
* : **x(1)*
* , **y(2)*
* , **z(3)*
*{*
*}*

Benefits:
* Members are aligned(easy to read)
* Eazyer for adding new members to the end of the list(no need to worry
about the comma to last entry)

br, Boris..

On Mon, Mar 23, 2015 at 4:59 AM, Marcos Cardinot <mcardinot at gmail.com>
wrote:

> Hello folks,
>
> It is just a naive discussion about coding style... =D
>
> According to the CodingStyle.txt:
>
> *"- in a C++ constructor initialization list, the colon is on the same
> line and*
> *  continuation lines are aligned as the rule above:*
>
> * ClassName::ClassName() : x(1), y(2),*
> * z(3)*
> * {*
> * }"*
>
> As you know, most of the classes does not follow this rule yet, but it's
> fine, since it looks like a new rule =D
>
> However, in this format, the next lines would usually require some white
> spaces (in order to do a correct alignment), but it might not be a good
> idea, because the alignment would depends on the editor...
> In addition, writing many (more than one) members at the same line is less
> readable than writing only one...
>
> My suggestion is that for this case, we should have a style in which we
> would never need to use white spaces...
> for example:
> *ClassName::ClassName() :*
> *x(1),*
> *y(2),*
> *z(3)*
> *{*
> *}*
>
> *or*
>
> *ClassName::ClassName()*
> * : **x(1),*
> *y(2),*
> *z(3)*
> *{*
> *}*
>
> But that's just my two cents.
>
> What do you think?
>
> All the best,
> Marcos
>
> _______________________________________________
> subsurface mailing list
> subsurface at subsurface-divelog.org
> http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
>
>


-- 
*Boris Barbulovski*
http://mkfusion.bokicsoft.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20150323/0f9a4a56/attachment.html>


More information about the subsurface mailing list