Untitled
unknown
plain_text
2 years ago
1.4 kB
7
Indexable
#pragma once #include <iostream> #include <string> using namespace std::string_view_literals; class IdentityDocument { public: IdentityDocument() : unique_id_(++unique_id_count_) { this->del = &IdentityDocument::Del; this->vMethod = &IdentityDocument::Id; std::cout << "IdentityDocument::Ctor() : "sv << unique_id_ << std::endl; } ~IdentityDocument() { --unique_id_count_; std::cout << "IdentityDocument::Dtor() : "sv << unique_id_ << std::endl; } IdentityDocument(const IdentityDocument& other) : unique_id_(++unique_id_count_) { std::cout << "IdentityDocument::CCtor() : "sv << unique_id_ << std::endl; } IdentityDocument& operator=(const IdentityDocument&) = delete; void PrintID() const { (this->*vMethod)(); } static void PrintUniqueIDCount() { std::cout << "unique_id_count_ : "sv << unique_id_count_ << std::endl; } int GetID() const { return unique_id_; } void Delete() { (this->*del)(); } private: void (IdentityDocument::*del)(); void (IdentityDocument::*vMethod)()const; static int unique_id_count_; int unique_id_; void Id() const { std::cout << "IdentityDocument::PrintID() : "sv << unique_id_ << std::endl; } void Del() { delete this; } }; int IdentityDocument::unique_id_count_ = 0;