boost::shared_array<char const *> x(new char const *[n]);
In the line above (n
is integer number not greater than 100) I'm creating char const**
(const char**
) and putting it to smart pointer x
for arrays to be deleted when x
is deleted. And for me it is clearly how and why this work.
boost::shared_array<char const *> x = new char const *[n];
Now lets take a look to second line. Here in my opinion we do exactly the same as in first case. Yes at first glance we may seem that here we constructing x via NULL
(default value of shared_array constructors parameter) then calling operator=
, but this is mistake, and as I know in this case instead of operator=
will be called constructor
with pointer created by new opeartor
.
But in spit of this I'm getting error C2440: 'initializing' : cannot convert from 'const char **' to 'boost::shared_array<T>
The only problem I see this is the explicit constructor of boost::shared_array<T>
. But I don't know what is the problem? Why does explicit constructor cause this error? And if the problem is not in explicit constructor, then where, why?