I have a program broken into two source files:
example.cpp
#include <iostream> class A { public: A(int x) { ::std::cout << "In A(" << x << ")\n"; } }; static A first(1); static A second(2);
example__main.cpp
int main(int argc, const char *argv[]) { return 0; }
Is the release of this program a guarantee:
In A(1) In A(2)
on all platforms and compilers? If so, where in the standard does it say? Does it matter if I use namespaces and firstand secondappear in different namespaces? How about if they are not static and I use an anonymous namespace?
first
second
, , .
++ 03,
(3.6/2) , , . [: 8.5.1 , . 6.7. ]
:
-, , " ", (. ).
" " .
" ", "" ( ).
( - "", ). TU .
: " ", ( , constexpr), static ( ): static int a; Foo b(1, true, Blue); , - "", non-constexpr, " ". , , ""; "" ..
constexpr
static
static int a; Foo b(1, true, Blue);
( , ++ 11, .)