#include <xtd/console>
class id_info :
public object {
public:
int id_number = 0;
explicit id_info(int id_number) : id_number {id_number} {}
};
class person :
public object {
public:
int age = 0;
return memberwise_clone<person>();
}
auto other = memberwise_clone<person>();
other->id_info = new_ptr<::id_info>(this->id_info->id_number);
other->name = new_ptr<string>(*name);
}
};
void display_values(
const person
p) {
}
auto main() -> int {
auto p1 = new_uptr<person>();
p1->age = 42;
*p1->name = "Sam";
*p1->id_info = id_info {6565};
auto p2 = p1->shallow_copy();
display_values(*p1);
display_values(*p2);
p1->age = 32;
*p1->name = "Frank";
p1->id_info->id_number = 7878;
display_values(*p1);
display_values(*p2);
auto p3 = p1->deep_copy();
*p1->name = "George";
p1->age = 39;
p1->id_info->id_number = 8641;
display_values(*p1);
display_values(*p3);
}
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:42
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.h:27
std::unique_ptr< type_t > uptr
The xtd::uptr object is a unique pointer.
Definition uptr.h:25
@ other
The operating system is other.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
In this example, the