Mark said:
#include <iostream>
using namespace std;
unsigned int main(unsigned int argc,
BTW, the return type of 'main()' is 'int' according to
the standard, not 'unsigned int'. The same applies to
the first argument.
char* argv[])
{
unsigned int i;
cout << i << endl;
return 0;
}
I don't see any mention of 'valarray' in this file. Also,
I don't see any trace of default initializing a built-in
value. Default initialization is typically requested by
tagging a pair of parenthesis on the appropriate type or
member. For example:
/**/ template <typename T>
/**/ struct foo {
/**/ foo():
/**/ member() // <--- this is default initialization
/**/ {}
/**/ T member;
/**/ };
You can try it out: if you instantiated this class with an
'unsigned int' (or some other built-in type) it should always
be zero. You can also verify that without the default
initialization the value of 'member' is not necessarily zero
(although there is no guarantee that it is not initialized)
if you remove the mention of 'member' in the member
initializer list. Here is a small program displaying this:
/**/ #include <new>
/**/ #include <iostream>
/**/ int main() {
/**/ void* mem = operator new(sizeof(foo<int>));
/**/ foo<int>* obj = new(mem) foo<int>;
/**/ std::cout << obj->member << "\n";
/**/ obj->member = 17;
/**/ obj->~foo<int>();
/**/ obj = new(mem) foo<int>;
/**/ std::cout << obj->member << "\n";
/**/ obj->~foo<int>();
/**/ operator delete(mem);
/**/ }
For members with class types the default initialization is kind
of redundant because it would happen even if the member was not
mentioned in the member initializer list. For members with
built-in, POD, or aggregate types it makes a difference though:
these stay uninitialized (for aggregates only members of POD
or built-in types would be uninitialized; aggregate members
with class type are, of course, default constructed).