width,int height)
{
itswidth=width;\\,2),int height).drawshape();
}
void rectangle:rectangle(int width.
#include <,int height) const
{
for(int i=0:;
}
}
int main()
{
rectangle therect(30;:
int itswidth;
rectangle;
std;drawshape();
therect:drawshape()const
{
drawshape(itswidth;n"
therect;
~rectangle(){}
void drawshape() const,int aheight) const;
int itsheight;n",如果是重载应该是drawshape()的反回值再被drawshape()调用;
return 0::,5),清单10;i++)
{
for (int j=0;
itsheight=height;"
};n"ndrawshape(40:,itsheight);<
std;<:cout<;
private;i<
}
std:cout<::drawshape(int width.有些不理解;<:;",2):.1的一个例子;"j<
}
书上讲解29行到49行用了函数的重载;height这是21天学能C++第十单:\iostream>j++)
{
std.drawshape(40:
rectangle(int width;
class rectangle
{
public:cout<":cout<*"
}
void rectangle:\.这里有些看不懂;
void drawshape(int awidth;<
C++实例,关于函数重载的一个问题!
答案:2 悬赏:0
解决时间 2021-04-21 08:23
- 提问者网友:無奈小影
- 2021-04-21 03:49
最佳答案
- 二级知识专家网友:青春如此荒謬
- 2021-04-21 04:26
重载是C++的多态的一个体现,(多态的另外一个体现在虚函数),你说的是函数调用
重载是知相同的函数名在不同的地方出现不同的功能
通过函数的返回值以及参数的类型与个数来区分在什么时候调用哪一个同名函数
重载是知相同的函数名在不同的地方出现不同的功能
通过函数的返回值以及参数的类型与个数来区分在什么时候调用哪一个同名函数
全部回答
- 1楼网友:佛说妍妍很渣
- 2021-04-21 05:49
第一个函数名写的是disp"al"y,其它的写的是disp"la"y,下面调用的全是disp"al"y.注意打引号的部分
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯