📄 delegation.cpp
字号:
#include <iostream>
using namespace std;
class Rectangle
{
public:
Rectangle( int height, int width ) : _height( height ), _width( width )
{
}
public:
int Area()
{
return _height*_width;
}
private:
int _height;
int _width;
};
class Target
{
virtual int Area() = 0;
};
class Window : public Target
{
public:
Window( Rectangle& rect ) : _rect( rect )
{
}
public:
int Area()
{
return _rect.Area();
}
private:
Rectangle& _rect;
};
int main()
{
Rectangle rect( 10, 20 );
Window win( rect );
win.area();
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -