[prog] [C] strings bug

Dan Richter daniel.richter at wimba.com
Fri Apr 11 10:09:17 EST 2003

Wow, I didn't know that uninitialized variables were set to zero 
automatically in C++.

However, a quick test with the GCC shows that only global variables are 
automatically initialized; local variables are not.

Interestingly, I was taught that in C++, built-in types had a "constructor" 
that you could call like this:
   int a();
   int* p = new int();
In these cases, according to what I learned, the parentheses call the 
"constructor" to be called, initializing the variables to zero. HOWEVER, 
the GCC didn't accept the syntax.

I would also note that, with the GCC, all ints allocated using "new" are 
automatically initialized to zero.

But let me finish by saying that depending on automatic intialization is a 
really bad idea.

========== Dan Richter ============== mailto:Dan at wimba.com ===========
  [Larry] Wall [inventor of Perl] believes that people think about
  things in different ways, that natural languages accommodate many
  mindsets, and that programming languages should too.
    - Jon Udell, in his essay, "A Perl Hacker in the Land of Python"

More information about the Programming mailing list