Quantcast
Channel: User Peter - Reinstate Monica - Stack Overflow
Viewing all articles
Browse latest Browse all 223

Answer by Peter - Reinstate Monica for memset() to initialize object in constructor?

$
0
0

The "memset approach" has two advantages over initializers for structures which are large but simple collections of data: It is clearer and has better maintainability.

  • Clearer because it is obvious and easily verifiable what happens. With single initializations, a reviewer must verify that no member is omitted. (A good compiler called with a sufficiently high warning setting will warn, but in a large project warnings easily drown in the noise.)
  • Better to maintain because the code stays correct even if a member is added.

Viewing all articles
Browse latest Browse all 223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>