Is subscripting an alphanumeric a common/valid technique? And what are the implicit conversions that take place ? example :
#include <iostream>
using namespace std;
int main()
{
int k(2);
cout << "Hello"[k] << endl;
cout << (k-1)["Hello"] << endl;
// your code goes here
return 0;
}
It's not particular common to index literal strings, but it has its uses, e.g.
auto hex_digit( int const value )
-> char
{
assert( 0 < value && value < 0x10 );
return "0123456789ABCDEF"[value];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With