SHOW:
|
|
- or go back to the newest paste.
1 | - | class Shape; |
1 | + | |
2 | ShapeContainer::ShapeContainer( const ShapeContainer & other ){ | |
3 | - | typedef std::unique_ptr<Shape> shape_ptr; |
3 | + | |
4 | m_vect.push_back(other.m_vect[i]->clone()); | |
5 | - | class Shape{ |
5 | + | |
6 | ||
7 | - | public: |
7 | + | auto begin = other.m_vect.begin(); |
8 | - | Shape(){}; |
8 | + | auto end = other.m_vect.end(); |
9 | - | virtual ~Shape(){}; |
9 | + | std::transform(begin, end, std::back_inserter(m_vect), [](ShapePtr const& p) |
10 | { return p.clone(); }); | |
11 | - | virtual void draw() const = 0; |
11 | + | |
12 | - | virtual float area() const = 0; |
12 | + | for(auto&& p: other.m_vect) { |
13 | m_vect.push_back(p.clone(); | |
14 | - | virtual shape_ptr clone() const = 0; |
14 | + | } |
15 | - | virtual shape_ptr create() const = 0; |
15 | + |