cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Initial values of variables
Initial values of variables
Jun 26, 2011 at 7:08am UTC
tonnot
(335)
About initialization of variables...(read here in cpluplus)
When declaring a regular local variable, its value is by default undetermined
Is there a way to tell that all numeric variables of my program have a default value of 0.
?
Thanks
Last edited on
Jun 26, 2011 at 7:08am UTC
Jun 26, 2011 at 8:11am UTC
jsmith
(5804)
You have to explicitly assign them zero.
Or, much more verbosely, use boost::value_initialized, which is nothing more than a class that is intended to wrap a fundamental type and initialize it to zero when default constructed.
Topic archived. No new replies allowed.