You can provide an initializer for a newly created fundamental-type variable, as in
double *ptr = new double( 3.14159 );
which initializes a newly created double
to 3.14159
and assigns the resulting pointer to ptr
. The same syntax can be used to specify a comma-separated list of arguments to the constructor of an object. For example,
Time *timePtr = new Time( 12, 45, 0 );
initializes a new Time
object to 12:45 PM and assigns the resulting pointer to timePtr
.