return reference to element of dynamic array in C++? -


is how return reference element of dynamically allocated array index ??

    int& dynamic_array::operator[](unsigned int i) {     if (i >= get_size())         throw exception(subscript_range_exception);     else         return array[i]; } 

yes, correct – alexander shishenko

thanks


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -