prototype_pattern::ConcretePrototype2

class ConcretePrototype2 : public prototype_pattern::Prototype

Another concrete implementation of the Prototype interface.

ConcretePrototype2 represents a specific prototype with an integer attribute.

Public Functions

explicit ConcretePrototype2(int attribute)

Constructor to initialize the attribute.

Parameters:

attribute – The value to initialize the prototype’s attribute.

virtual std::unique_ptr<Prototype> clone() const override

Creates a clone of the current object.

Creates a clone of the ConcretePrototype2 object.

This method is implemented by derived classes to return a copy of the current object.

Creates a new instance of ConcretePrototype2 by copying the current object’s attribute.

Performs a deep copy of the current object, creating an independent instance.

Returns:

A unique pointer to the cloned object.

Returns:

A unique pointer to the cloned ConcretePrototype2.

virtual void display() const override

Displays the details of the prototype.

Displays the details of the ConcretePrototype2.

This method is implemented by derived classes to provide a textual representation of the object.

Outputs the value of the attribute.

Outputs the value of the attribute to the standard output.