c++ - Why can the new operator be with an initial value? -
as know new operator can used in following way: int *a = new int(10); , means there int pointer named points initial value equals 10. in http://www.cplusplus.com , couldn't find such direction , want know why new operator can used initial value? similar constructor calling?
why new operator can used initial value?
the initial value (10) goes object (int) *a points.
is similar constructor calling?
yes.
also works auto vars
int b (20);
b initialized 20.
Comments
Post a Comment