Quotidian

An occasionally updated blog, mostly related to programming. (Views are my own, not my employer's.)

Thursday, January 31, 2008

C++ static arrays are initialized every time

The language would be very broken if this wasn't true, but I'm happier having some verification of this anyway:
#include <iostream>
using namespace std;

int main()
{
for (int i = 0; i < 3; ++i) {
int a[1] = {13};
cout << a[0] << endl;
}
return 0;
}
$ g++ array_init_every_time.cpp
$ ./a.out
13
13
13
Posted by util at 1:29 PM
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: C++

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Blog Archive

  • ►  2024 (2)
    • ►  January (2)
  • ►  2023 (7)
    • ►  December (1)
    • ►  October (1)
    • ►  July (1)
    • ►  June (1)
    • ►  May (2)
    • ►  February (1)
  • ►  2022 (3)
    • ►  August (2)
    • ►  January (1)
  • ►  2021 (12)
    • ►  June (1)
    • ►  May (3)
    • ►  April (7)
    • ►  March (1)
  • ►  2020 (2)
    • ►  December (1)
    • ►  September (1)
  • ►  2013 (1)
    • ►  December (1)
  • ►  2009 (1)
    • ►  March (1)
  • ▼  2008 (67)
    • ►  June (15)
    • ►  May (15)
    • ►  April (9)
    • ►  March (12)
    • ►  February (6)
    • ▼  January (10)
      • C++ static arrays are initialized every time
      • Do I think in closures?
      • Another way to print a matrix in Maxima
      • Create a diagonal matrix in Maxima
      • Approaching normality
      • C code for reading a CSV file
      • ifelse(o, a, b)
      • A few string functions for working with case
      • moment generating functions in R
      • an incomplete family
  • ►  2007 (2)
    • ►  December (1)
    • ►  November (1)

About Me

util
View my complete profile
Powered by Blogger.