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

twig - Using Twigbridge in a Laravel 5.1 Package -

php - Symfony 2: "No route found for "GET /" - error on fresh installation -

java - Openshift port-forwarding -