64,654
社区成员
发帖
与我相关
我的任务
分享
string screenInit(string::size_type height = 24,
string::size_type width =80,
char background = ' ')
string screen;
screen = screenInit(); //equivalent to screeenInit(24,80,' ')
所以,我认为你的两个函数是重定义的#include<iostream>
using namespace std;
class Rectangle
{
private:
double length,width;
public:
Rectangle(); //声明无参数的构造函数
Rectangle(double a,double b); //声明带两个参数的构造函数
void area();
};
Rectangle::Rectangle()
{
length=1;
width=1;
}
Rectangle::Rectangle(double a/*=1*/,double b/*=1*/)
{
length=a;
width=b;
}
void Rectangle::area()
{
cout<<"面积是:"<<length*width<<endl;
}
int main()
{
Rectangle rect1;
rect1.area();
Rectangle rect2(5,6);
rect2.area();
system("pause");
return 0;
}