I haven’t written in c ++ for a long time, this problem arose
There is an array of pointers to class objects, say
It is necessary to sort the array in ascending order; when sorting, it is natural to have to rearrange elements in places, i.e. one pointer to assign the value of another, please tell me how to do it. I do about the following:
Class1* Array = new Class1[n]; Class1* temp = &Array[j+1]; // здесь все хорошо Array[j+1] = &Array[j]; // а как быть тут? Array[j] = temp; // и тут?
In the 2nd and 3rd line of the code, it turns out that the left-handed pointer, i.e. the object itself and the link to the right
How do you yourself refer to the left side as a pointer?