shapedecorator.cpp

来自「financal instrument pricing using c」· C++ 代码 · 共 55 行

CPP
55
字号
// ShapeDecorator.hpp
//
// Base class for shape decorators
//
// 5 november 1998	RD	Started
//
// (C) Datasim Education BV 1998

#include "ShapeDecorator.hpp"

ShapeDecorator::ShapeDecorator(): Shape()
{ // Default constructor

	shape=NULL;
}

ShapeDecorator::ShapeDecorator(const Shape& s): Shape(s)
{ // Normal constructor

	shape=s.Clone();
}

ShapeDecorator::ShapeDecorator(const ShapeDecorator& source): Shape(source)
{	// Copy constructor

	shape=source.shape->Clone();
}

ShapeDecorator::~ShapeDecorator()
{ // Destructor

	// Delete the contained shape
	if (shape!=NULL) delete shape;
}

Shape* ShapeDecorator::getShape() const
{ // Return the shape pointer

	return shape;
}

// Operators
ShapeDecorator& ShapeDecorator::operator = (const ShapeDecorator& source)
{ // Assignment operator

	// Exit if same object
	if (this==&source) return *this;

	// Call base assignment
	Shape::operator = (source);

	shape=source.shape->Clone();

	return *this;
}

⌨️ 快捷键说明

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