Shows hows how to use xtd::object::get_type method.
#include <xtd/as>
#include <xtd/console>
class my_base_class :
public object {
};
class my_derived_class: public my_base_class {
};
auto main() -> int {
auto my_base = my_base_class {};
auto my_derived = my_derived_class {};
object&
o = as<object>(my_derived);
my_base_class&
b = as<my_base_class>(my_derived);
console::write_line("my_base: type is {}", my_base.get_type());
console::write_line("my_derived: type is {}", my_derived.get_type());
console::write_line(
"object o = my_derived: type is {}",
o.get_type());
console::write_line(
"my_base_class b = my_derived: type is {}",
b.get_type());
console::write_line();
console::write_line(
"my_base: type is {}",
typeof_(my_base));
console::write_line(
"my_derived: type is {}",
typeof_(my_derived));
console::write_line(
"object o = my_derived: type is {}",
typeof_(o));
console::write_line(
"my_base_class b = my_derived: type is {}",
typeof_(b));
}
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:42
#define typeof_
Used to obtain the type object of a specified type or object.
Definition typeof.h:45
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10