by Juha Nieminen <nospam@[EMAIL PROTECTED]
>
May 8, 2008 at 10:44 AM
Jerry Coffin wrote:
> class key {
> string name;
> string prefix;
> public:
> key(string n, string p) : name(n), prefix(p) {}
> key(key const &other) : name(other.name), prefix(other.prefix) {}
> key &operator=(key const &other) {
> name = other.name;
> prefix = other.prefix;
> return *this;
> }
What exactly do you need that copy constructor and assignment operator
for? They are doing exactly what the default ones would do. They are
useless.
How about simply:
struct Key
{
std::string name, prefix;
Key(std::string& n = "", std::string p = ""): name(n), prefix(p) {}
bool operator<(const Key& rhs)
{
return name == rhs.name ? prefix < rhs.prefix : name < rhs.name;
}
}