Реализации на С++
Builder
Общая реализация на языке С++
class Car
{
public:
virtual ~Car() = default;
virtual void drive() = 0;
};
class Sedan : public Car
{
public:
Sedan()
{
cout << "Calling the Sedan constructor;" << endl;
}
~Sedan() override
{
cout << "Calling the Sedan destructor;" << endl;
}
void drive() override
{
cout << "Calling the drive method;" << endl;
}
};
# include <iostream>
# include <memory>
using namespace std;
int main()
{
shared_ptr<CarBuilder> builder = make_shared<SedanBuilder>();
shared_ptr<CarCreator> creator = make_shared<CarDirector>(builder);
User{}.use(creator);
}
Last updated
Was this helpful?