📄 高级函数.cpp
字号:
#include<iostream>
using namespace std;
class rectangle
{
public:
rectangle(int width,int height);
~rectangle(){}
void drawshape()const;
void drawshape(int awidth,int aheight)const;
private:
int itswidth;
int itsheight;
};
rectangle::rectangle(int width,int height)
{
itswidth=width;
itsheight=height;
}
void rectangle::drawshape()const
{
drawshape(itswidth,itsheight);
}
void rectangle::drawshape (int width,int height)const
{
for(int i=0;i<height;i++)
{
for(int j=0;j<width;j++)
cout<<"*";
cout<<endl;
}
}
int main()
{
rectangle therect(30,5);
cout<<"drawshape():\n";
therect.drawshape ();
cout<<"\ndrawshape (40,2):\n";
therect.drawshape (40,2);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -