bu kod var Diyelim?polimorfik operatörü [] uygulanması
O
int main()
{
test_t test;
int t = test[5];
double f = test[7];
return 0;
}
yani gibi görünmelidir bir polimorfik operatör []. Eğer yapmak Sen obj.get<T>(index)
için ya da çok benzer bir şey için çare olabilir bir proxy nesne
struct Proxy {
template<typename T>
operator T() {
return static_cast<T*>(data)[index];
}
void *data;
int index
};
Proxy operator [](int index)
{
Proxy p = { data, index };
return p;
}
dönmek için elinden olduğu Ne
Bu, polimorfizm değildir. – SLaks
@SLaks: Tabii ki bu bir çeşit polimorfizm. –