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

Popular posts from this blog

gcc - MinGW's ld cannot perform PE operations on non PE output file -

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

c# - Search and Add Comment with OpenXML for Word -