D
DaKoadMunky
I recently came across some code in a template that default constructed an
object of type T to pass to another function...
SomeFunction(T());
The code that instantiates that template specifies T as an int.
Proper program behavior relies on that "default constructed" int being zero.
That lead me to the following example...
int main()
{
int i; //Uninitialized! Expected for automatic of built-in type
int j = int(); //Initialized to zero! Not sure what to expect
return 0;
}
Is such "default construction" of built-in types standard C++?
char() == 0
int()==0
etc...
Thanks
object of type T to pass to another function...
SomeFunction(T());
The code that instantiates that template specifies T as an int.
Proper program behavior relies on that "default constructed" int being zero.
That lead me to the following example...
int main()
{
int i; //Uninitialized! Expected for automatic of built-in type
int j = int(); //Initialized to zero! Not sure what to expect
return 0;
}
Is such "default construction" of built-in types standard C++?
char() == 0
int()==0
etc...
Thanks