Derleyicim (GCC) neden örtülü olarak char**
'ten const char**
'e dönüştürülmez?Char ** 'den const char'e örtülü dönüştürme **
Şu kodu takip ediyor:
#include <iostream>
void print(const char** thing) {
std::cout << thing[0] << std::endl;
}
int main(int argc, char** argv) {
print(argv);
}
Aşağıdaki hatayı veriyor:
oi.cpp: In function ‘int main(int, char**)’:
oi.cpp:8:12: error: invalid conversion from ‘char**’ to ‘const char**’ [-fpermissive]
oi.cpp:3:6: error: initializing argument 1 of ‘void print(const char**)’ [-fpermissive]
[Neden Foo ** '→ Foo const **' dönüştüren bir hata alıyorum? (Http://www.parashift.com/c++-faq-lite/const-correctness.html#faq -18.17) – fredoverflow
"Kapalı yayın" diye bir şey yoktur. Bir "cast", bir dönüşümü belirten açık bir operatördür. Ayrıca, örtülü dönüşümler de olabilir. ("cast" operatördür, "conversion" işlemidir.) –
@Keith: Bence terminoloji bir problem değil. Sonuçta, "up-cast" ve "up-conversion" demiyoruz. Ya da en azından bunu söylüyorum. :-) –