xtd 0.2.0
string_builder_append.cpp

Shows how to use xtd::text::basic_string_builder::append method.

#include <xtd/text/string_builder>
#include <xtd/console>
#include <xtd/istringable>
using namespace xtd;
class dog : public istringable {
private:
string dog_breed;
string dog_name;
public:
dog(const string& name, const string& breed) : dog_breed(breed), dog_name(name) {}
const string& breed() const noexcept {return dog_breed;}
const string& name() const noexcept {return dog_name;}
string to_string() const noexcept override {return dog_name;}
};
auto main() -> int {
auto dog1 = dog {"Mocka", "American Shepherd"};
sb.append(dog1).append(", breed: ").append(dog1.breed());
}
// This code produces the following output :
//
// Mocka, breed: American Shepherd
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
Provides a way to represent the current object as a string.
Definition istringable.hpp:22
xtd::text::basic_string_builder< char > string_builder
Represents a mutable string of characters of UTF-8 code units. This class cannot be inherited.
Definition string_builder.hpp:19
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
string to_string() const noexcept override
Returns the string representation of this xtd::read_only_span <type_t> object.
Definition read_only_span.hpp:375