#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>();
}
uptr<person> deep_copy() {
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 {
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.hpp:44
xtd::unique_ptr_object< type_t > uptr
The xtd::uptr object is a unique pointer.
Definition uptr.hpp:25
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.hpp:27
ptr< type_t > new_ptr(args_t &&... args)
The xtd::new_ptr operator creates a xtd::ptr object.
Definition new_ptr.hpp:24
uptr< type_t > new_uptr(args_t &&... args)
xtd::new_uptr operator. This operator creates a xtd::uptr object.
Definition new_uptr.hpp:24
@ other
The operating system is other.
Definition platform_id.hpp:58
@ p
The P key.
Definition console_key.hpp:118
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8