xtd 0.2.0
interface.cpp

Shows how to use xtd::interface class.

#include <xtd/as>
#include <xtd/interface>
#include <xtd/console>
using namespace xtd;
namespace interface_example {
public:
virtual string to_string() const = 0;
};
class program : public istringable {
public:
program() = default;
string to_string() const override {return "program";}
};
}
auto main() -> int {
console::write_line(stringable->to_string());
}
// This code produces the following output :
//
// program
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
#define interface_
This keyword is use to represent an interface.
Definition interface.hpp:58
ptr< type_t > new_ptr(args_t &&... args)
The xtd::new_ptr operator creates a xtd::ptr object.
Definition new_ptr.hpp:24
type_t as(any_object &o)
Casts a type into another type.
Definition __as_any_object.hpp:59
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