I'm new with C++ and came to this problem, here is my code:
shared_ptr<char[]>var(new char[20]);
char *varptr = *(var.get());
So I'm creating smart pointer of char array.
The problem that I'm having is that during compilation it gives me error saying:
cannot convert argument 1 from 'char *' to 'char(*)[]'
As the declaration of shared_ptr::get
says T* get() const noexcept;
it returns the pointer of template, in my case pointer to char[]
. Dereferencing it should give me the char[]
and assigning it to char*
should be ok.
It seems like I'm missing something and can't figure out what.
What is the difference between char*
and char(*)[]
? Isn't char(*)[]
just a pointer of char array? Shouldn't assigning it to char*
be ok?