"Default construction" of built-in types?
From: DaKoadMunky (dakoadmunky_at_aol.com)
Date: 05/29/04
- Next message: Victor Bazarov: "Re: Simple iterator usage question..."
- Previous message: Mitchell: "Re: GOF Interface Problem"
- Next in thread: Victor Bazarov: "Re: "Default construction" of built-in types?"
- Reply: Victor Bazarov: "Re: "Default construction" of built-in types?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 29 May 2004 03:09:46 GMT
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
- Next message: Victor Bazarov: "Re: Simple iterator usage question..."
- Previous message: Mitchell: "Re: GOF Interface Problem"
- Next in thread: Victor Bazarov: "Re: "Default construction" of built-in types?"
- Reply: Victor Bazarov: "Re: "Default construction" of built-in types?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|