advertisement
Login | Register   
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   TIP BANK
Browse DevX
Is "initialize all automatic variables" included in your code review checklist? Which forms of initialization do you use—memset() (or a similar library function) or the forms shown in this article? Let us know in the DevX c++.general discussion group.
Partners & Affiliates
advertisement
advertisement
advertisement
advertisement
 

Take Charge and Initialize Your Own Data

C++ doesn't initialize automatic variables for you, and if you're unfamiliar with the right syntax or aggregate initialization, you can misuse important library functionsor you might be tempted to skip initialization altogether. Avoid creating unnecessary performance overhead, future maintenance problems, and potential bugs by learning how to correctly initialize data on your own.  


advertisement
nlike most other programming languages, C++ by default doesn't initialize automatic variables. Consequently, uninitialized auto variables and aggregates have an indeterminate value.



Due to insufficient familiarity with the correct syntax of aggregate initialization, many programmers either misuse library functions such as memset() or forgo initialization altogether, thereby incurring unnecessary performance overhead, future maintenance problems, and potential bugs.


It's quick, easy and you get access to all the articles on DevX.
This registration/login is to allow you to read articles on devx.com.
Already a member?



advertisement