class Dynarr { private: double * arr; int size; public: double & operator[](int pos) { cout << " hey " << size << endl; return arr[pos]; }; Dynarr * operator=(Dynarr * rhs) { *this = Dynarr(rhs->size, rhs->arr); }; }; int main() { double * darr = new double[5]; darr[0] = 0; darr[1] = 1; darr[2] = 2; darr[3] = 3; darr[4] = 4; Dynarr * arrr1 = new Dynarr(5, darr); cout << arrr1[1] << endl; system("pause"); return 0; } As in line
cout << arrr1[1] << endl; access the second element of the arr array?
(*arrr1)[1]sincearrr1is a pointer to an instance of a class with an overloaded operator. - VTT