#include <xtd/environment>
#include <xtd/format>
#include <xtd/println>
public:
character() = default;
character(const string& name, const string& rank) noexcept : name_(name), rank_(rank) {}
const string& name() const noexcept {return name_;}
const string& rank() const noexcept {return rank_;}
string to_string() const noexcept {return to_string("", std::locale {});}
string to_string(const string& format, const std::locale& loc) const override {
auto fmt = string::is_empty(format) ? "F" : format;
if (fmt == "F") return name_ + " (" + rank_ + ")";
if (fmt == "N") return name_;
if (fmt == "R") return rank_;
}
private:
string name_;
string rank_;
};
auto main() -> int {
try {
auto char1 = character {"Jean-Luc Picard", "Captain"};
}
}
Defines the base class for predefined exceptions in the xtd namespace.
Definition exception.hpp:28
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
void println(FILE *file)
Writes the current line terminator to the file output stream using the specified format information.
Definition println.hpp:14