xtd 0.2.0
Loading...
Searching...
No Matches
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 {
auto stringable = as<interface_example::istringable>(new_ptr<interface_example::program>());
console::write_line(stringable->to_string());
}
// This code produces the following output :
//
// program
Provides a way to represent the current object as a string.
Definition istringable.h:23
#define interface_
This keyword is use to represent an interface.
Definition interface.h:58
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10