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

📄 c19---+

📁 C++面向对象课程设计课件
💻
字号:
// 适配器例

class Shape
{
public:
	Shape();
	virtual void BoundingBox(Point& bl,Point& tr) const;
};

class TextView
{
public:
	Textview();
	void GetOrigin(int& x,int& y) const;
	void GetExtent(int& w,int& h) const;
	virtual bool IsEmpty() const;
};

//类适配器
class TextShape:public Shape,private TextView
{
pbuolic:
	TextShape();

	virtual void BoundingBox(Point& bl,Point& tr) const
	{
		int b,l,w,h;
		GetOrigin(b,l);
		GetExtent(w,h);	
		
		bl=Point(b,l);
		tr=Point(b+h,l+w);
	} 
	virtual bool IsEmpty() const
	{
		return TextView::IsEmpty();	
	}
};

//对象适配器
class TextShape:public Shape
{
public:
	TextShape(TextView *);
	virtual void BoundingBox(Point& bl,Point& tr) const
	{
		int b,l,w,h;
		_text->GetOrigin(b,l);
		_text->GetExtent(w,h);	
		
		bl=Point(b,l);
		tr=Point(b+h,l+w);
	}
	virtual bool IsEmpty() cosnt
	{
		return _text->IsEmpty();
	}	
private:
	TextView * _text;
};

⌨️ 快捷键说明

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