Untitled
unknown
plain_text
4 years ago
1.1 kB
13
Indexable
#pragma once
#include "identity_document.h"
#include <iostream>
#include <string>
using namespace std::string_view_literals;
class DrivingLicence {
public:
operator IdentityDocument()
{
return IdentityDocument();
}
DrivingLicence()
{
this->vMethod = &DrivingLicence::Id;
this->del = &DrivingLicence::Del;
vtable = new IdentityDocument();
std::cout << "DrivingLicence::Ctor()"sv << std::endl;
}
DrivingLicence(const DrivingLicence& other)
{
IdentityDocument a(*other.vtable);
std::cout << "DrivingLicence::CCtor()"sv << std::endl;
}
~DrivingLicence() {
std::cout << "DrivingLicence::Dtor()"sv << std::endl;
delete vtable;
}
void PrintID() const
{
(this->*vMethod)();
}
void Delete()
{
(this->*del)();
}
private:
void (DrivingLicence::*del)();
void (DrivingLicence::*vMethod)()const;
IdentityDocument* vtable;
void Id() const
{
std::cout << "DrivingLicence::PrintID() : "sv << vtable->GetID() << std::endl;
}
void Del()
{
delete this;
}
};
Editor is loading...