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]; }
1.4m articles
1.4m replys
5 comments
57.0k users