xtd 0.2.0
Loading...
Searching...
No Matches
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());
console::write_line(sb);
}
// This code produces the following output :
//
// Mocka, breed: American Shepherd
Provides a way to represent the current object as a string.
Definition istringable.h:23
Represents a mutable string of characters. This class cannot be inherited.
Definition basic_string_builder.h:35
basic_string_builder & append(const xtd::basic_string< char_t > &value)
Appends a copy of the specified string to this instance.
Definition basic_string_builder.h:442
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10