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

📄 高级函数.cpp

📁 C++编写的程序源码,里有21天学通C++的课后作业源码和章节源码.
💻 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 + -