Skip to content

Instantly share code, notes, and snippets.

@acmorrow
Last active December 12, 2015 04:49
Show Gist options
  • Save acmorrow/4717282 to your computer and use it in GitHub Desktop.
Save acmorrow/4717282 to your computer and use it in GitHub Desktop.
// In C++11, one constructor can call another, so we don't need to rewrite
// the initializer list again() and again() and again() and again()...
struct Thing {
Thing(std::string name, Color color)
: name_(std::move(name))
, color_(color) {}
Thing(std::string name)
: Thing(name, Color::Green) {}
Thing(Color color)
: Thing("anonymous", color) {}
const std::string name_;
const Color color_;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment