I am writing a Grid class whose elements are Points - a (int) grids, each of whose squares has a (double) point in it. I already defined this (the height value is saved elsewhere):
Point &operator[](Point p) { return floor(get_x(p)) + height * floor(get_y(p)); }
and I want to define an assignment operator. How can I do that? Is this automatically determined based on the [] operator?
I still have
Point &operator[]=(Point p, Point q) { data[floor(get_y(p)) * height + floor(get_x(p))] = q; }
but it looks like a circular definition.
source share