⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shapecomposite.hpp

📁 financal instrument pricing using c
💻 HPP
字号:
// ShapeComposite.hpp
//
// Simple shape composite class using the STL list class.
// The composite stores shape pointers. It does it's own memory management.
//
// (C) Datasim Education BV

#ifndef ShapeComposite_hpp
#define ShapeComposite_hpp

#include "Shape.hpp"

#include <list>
class ShapeComposite: public Shape
{
private:
	// The shapelist using the STL list
	std::list<Shape*> sl;
	
	void Copy(const ShapeComposite& source);		// Copy the source composite to this shape composite



public:
	// User can use the STL iterator
	typedef std::list<Shape*>::iterator iterator;
	typedef std::list<Shape*>::const_iterator const_iterator;

	// Constructors and destructor
	ShapeComposite();								// Default constructor
	ShapeComposite(const ShapeComposite& source);	// Copy constructor
	virtual ~ShapeComposite();						// Destructor

	// Iterator functions
    iterator Begin();								// Return iterator at begin of composite
	const_iterator Begin() const;					// Return const iterator at begin of composite
	iterator End();									// Return iterator after end of composite
    const_iterator End() const;						// Return const iterator after end of composite

	// Selectors
	int Count() const;								// The number of shapes in the list

	// Add functions
	void AddFront(Shape* s);						// Add shape at the beginning of shapelist. No copy is made but composite takes care of deletion.
	void AddBack(Shape* s);							// Add shape at the end of shapelist. No copy is made but composite takes care of deletion.

	// Remove functions
	void RemoveFirst();								// Remove first shape
	void RemoveLast();								// Remove last shape
	void RemoveAll();								// Remove all shapes from the list

	// Special copy function to create a copy of a shape when you only have a shape pointer
	virtual Shape* Clone() const;		// Create a copy of the shape

	// Operators
	ShapeComposite& operator = (const ShapeComposite& source);
};

#endif	// ShapeComposite_hpp

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -