I have written functions to return const char*
without any problem:
class Test {
public:
const char* data() const {return data_;}
private:
char* data_;
};
int main()
{
Test test;
const char* temp = test.data();
return 0;
}
Today I need to return the const char**
, so I did the same thing:
class Test {
public:
const char** data() const {return data_;}
private:
char** data_;
};
int main()
{
Test test;
const char** temp = test.data();
return 0;
}
But it tells me:
main.cpp:15:39: error: invalid conversion from ‘char**’ to ‘const char**’ [-fpermissive]
const char** data() const {return data_;}
^~~~~
In MSVC it reports:
error C2440: 'return': cannot convert from 'char **const ' to 'const char **'
I know it it because the the const char** is not "fully const", it is the pointer of const char*, but the error message is really confused how to fix it.
My question is: What's the correct way to return a "fully const" char**? Thanks!