Function-style cast vs. constructor

后端 未结 3 1550
终归单人心
终归单人心 2021-02-20 14:38

I learned that in C++,

typedef foo* mytype;

(mytype) a        // C-style cast

and

mytype(a)         // function-style cast
         


        
3条回答
  •  抹茶落季
    2021-02-20 15:09

    The compiler knows. And it calls the constructor when there is one in both cases.

提交回复
热议问题