xtd 0.2.0
Loading...
Searching...
No Matches
interface2.cpp

Shows how to use xtd::interface class.

#include <xtd/as>
#include <xtd/interface>
#include <xtd/console>
using namespace xtd;
namespace interface2_example {
class istringable : public interface {
public:
virtual string to_string() const = 0;
};
class program : public istringable {
public:
program() = default;
string to_string() const override {return "program";}
};
}
auto main() -> int {
auto stringable = as<interface2_example::istringable>(new_ptr<interface2_example::program>());
console::write_line(stringable->to_string());
}
// This code produces the following output :
//
// program
Represent an interface class.
Definition interface.hpp:31
Provides a way to represent the current object as a string.
Definition istringable.hpp:23
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10