First of all, the class has very limited usability. Lookup by name will be much longer than lookup by id or index. Second, class
is not relevant here since it violates encapsulationhas setters and getters. I I would just write this:
#include <string>
struct named_point
{
float x;
float y;
std::string name;
}
Since the users need access to all members of the class, the members should be public. There is no real invariant to hold here. Using std::unique_ptr
for this job is somewhat odd. Use std::string
. It will cleanup your code dramatically, since it implements rule of 5 itself, a lot of burden will be lifted.