I have the following problem. I have a std::unordered_map that contains an object as the value. Now I want to modify an object that I previously inserted.
class Point
{
public:
Point(float _x, float _y) : x(_x), y(_y) {}
float x;
float y;
};
std::unordered_map<int, Point> points;
// ... add some values to it ...
points[1].x = 20.f; // error?
I get a weird long compile error about point not being able to be default constructed. The way I understand it operator [] returns a reference to the mapped type (aka the value), so why can't I modify it?
Pointclass so addPoint() : x(0), y(0) {}so a ctor that takes no params