Skip to content

Instantly share code, notes, and snippets.

@betseg
Created February 5, 2018 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save betseg/60c982cf1277ca732fdcaa92787ee54d to your computer and use it in GitHub Desktop.
Save betseg/60c982cf1277ca732fdcaa92787ee54d to your computer and use it in GitHub Desktop.
#include <iostream>
class Human {
public:
Human(std::string nin) {
name = nin;
}
Human() {
name = "foo";
}
std::string name;
};
class Group {
public:
Group(const Human& hin0, const Human& hin1) {
h0 = hin0;
h1 = hin1;
}
Human h0;
Human h1;
};
Group operator+(const Human& lhs, const Human& rhs) {
return Group(lhs, rhs);
}
bool operator==(const Group& lhs, const Group& rhs) {
return lhs.h0.name == rhs.h0.name && lhs.h1.name == rhs.h1.name;
}
int main() {
Human me("me");
Human you("you");
Group we(me, you);
std::cout << ((we == me + you) ? "true" : "false");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment