Last active
December 12, 2015 04:49
-
-
Save acmorrow/4717282 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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