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]; }
2.1m questions
2.1m answers
60 comments
57.0k users