J
James Aguilar
Quick question. Why, in the following code sample, can I not convert a
char ** to a const char **?
void test(const char **p)
{
cout << str(*p) << '\n';
}
int main()
{
char *str = new char[10];
char **pstr = &str;
test(pstr);
return 0;
}
My error output is:
1>------ Build started: Project: test, Configuration: Debug Win32
1>Compiling...
1>test.cpp
1>test.cpp(3) : error C2065: 'cout' : undeclared identifier
1>test.cpp(3) : error C3861: 'str': identifier not found
1>test.cpp(11) : error C2664: 'test' : cannot convert parameter 1
from 'char **' to 'const char **'
1> Conversion loses qualifiers
1>Build log was saved at "file://xxxxxx\Debug\BuildLog.htm"
1>test - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
Any help would be appreciated. I'm sure someone must have brought this
issue up before, but it's not easy to search for, let's put it that way.
char ** to a const char **?
void test(const char **p)
{
cout << str(*p) << '\n';
}
int main()
{
char *str = new char[10];
char **pstr = &str;
test(pstr);
return 0;
}
My error output is:
1>------ Build started: Project: test, Configuration: Debug Win32
1>Compiling...
1>test.cpp
1>test.cpp(3) : error C2065: 'cout' : undeclared identifier
1>test.cpp(3) : error C3861: 'str': identifier not found
1>test.cpp(11) : error C2664: 'test' : cannot convert parameter 1
from 'char **' to 'const char **'
1> Conversion loses qualifiers
1>Build log was saved at "file://xxxxxx\Debug\BuildLog.htm"
1>test - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
Any help would be appreciated. I'm sure someone must have brought this
issue up before, but it's not easy to search for, let's put it that way.