Реализации на С++
Prototype
Общая реализация на языке С++
class Car
{
public:
virtual ~Car() = default;
virtual unique_ptr<Car> clone() = 0;
};
class Sedan : public Car
{
public:
Sedan()
{
cout << "Calling the default constructor;" << endl;
}
Sedan(const Sedan& car)
{
cout << "Calling the Copy constructor;" << endl;
}
~Sedan() override
{
cout << "Calling the destructor;" << endl;
}
unique_ptr<Car> clone() override
{
return make_unique<Sedan>(*this);
}
};Last updated
Was this helpful?