Why shared_ptr has an explicit constructor

前端 未结 5 877
挽巷
挽巷 2020-12-19 17:19

I was wondering why shared_ptr doesn\'t have an implicit constructor. The fact it doesn\'t is alluded to here: Getting a boost::shared_ptr for this

(I f

5条回答
  •  清歌不尽
    2020-12-19 17:31

    int main() {
    
        int foo = 5;
        fun(&foo);
    
        cout << foo << endl; // ops!!
    
        return 0;
    }
    

提交回复
热议问题