Why doesn't auto_ptr construction work using = syntax

前端 未结 4 913
失恋的感觉
失恋的感觉 2020-12-16 20:04

I ran into a compiler error that didn\'t make much sense to me:

#include 
using namespace std;

auto_ptr table = db->query(\"se         
4条回答
  •  余生分开走
    2020-12-16 20:38

    Adding to what lothar said: Because the auto_ptr constructor is declared with the explicit keyword, you need to use an explict cast to create an auto_ptr from a raw pointer. (Before the introduction of explicit, implicit casting was the bane of many a new -- and experienced) C++ developer.)

提交回复
热议问题