Home

Phlip <phlipcpp@yahoo.com> wrote in message...
>
> It calls Averagetype::Averagetype(Sumtype const & x), which must exist (to
> within input type variations).
>
> Next, it could have been written with constructor notation:
>
> Averagetype(sum)
>
> Or as an elaborate_cast:
>
> static_cast<Averagetype>(sum)
>
> Question: Which is better style?

The C++ cast. It is so ugly, you can't ignore it!
Better error/warnings when compiling.

Also, it makes it easy to search for with an editor.
( search (non-whole word): "_cast<", will find 'em all. Try that with a
C-style cast! )

I use the 'constructor-notation' for simple things I know are (relatively)
safe:

for( int i(0); size_t( i ) < somevector.size(); ++i ){
// some op that needs an int.
}
.... the 'size_t( i )' shuts-up the compiler warning.

--
Bob R
POVrookie

previous
next

Re: Smart pointers and this
Re: sorteddict PEP proposal [started off as orderedict]
Re: Tutorial or Example (or Tutorial) of Using Canvas to Producea Plot
get wikipedia source failed (urrlib2)
Re: How to create a file on users XP desktop
paraprotex
paraprotex
paraprotex
paraprotex
paraprotex