Guys, I know this would indicate that I am too silly.. because I think I am missing some basic knowledge related to pointers.
Please tell me, in the following function, can I not use something like (*arrptr)+j on the left hand side? If yes, why? there is nothing constant declared. Even then I am getting this error.
I am calling this function as bsort(ptr, n); where ptr is an array of pointers to objects of person class and n is the number of elements in this array.
Secondly, Also please let me know if it is not valid to use the same function call bsort(ptr, n); and in the function definition, using bsort(person* myptr , int mynum) i.e. a normal pointer capturing the address of the array of pointers to objects? Like passing by value?
+ operator returns a constant object or a temporary object (referred to 'r-value' objects), it is to construct a new nonconstant object or calling special 'const qualified' methods. It is forbidden to call 'noncostant' methods or modify the object returned by + operator in any way. So, it is not possible to use such an object on the left side of the '='.
Moreover, as I can see, arrptr is double addressed type, i.e. you have to invoke dereference operator * twice to get the object the double pointer points to.
That is:
(*arrptr) + i -- an address
*((*arrptr)+i) -- an object itself
I'm sorry, I have failed to understand the second part of your message. May be someone else can help you...